This SQL tutorial is intended simply to function an introduction to the items you’ll be able to do with SQL (i.e. add data, take away information, modify information and question your data). it’s not designed to be a whole guide to the language and its syntax as that will take an entire book! the primary issue we want to try to to during this sql tutorial is to outline SQL. SQL (pronounced either seequel or esscuell) is that the language used to speak with {the information|the info|the information}base and to retrieve/update/delete information stored within the database in addition as maintaining the data structures (tables, indexes, constraints etc). The name SQL is an acronym for Structured question Language. it’s a non-procedural language designed to permit end-users to be able to retrieve or modify their information (and information structures) during a database while not having to fret regarding how this is often achieved. In alternative words it concentrates on what’s being done instead of the way to it’s done. As already hinted at, there are 2 forms of SQL statements.
DML (data manipulation language) for querying and updating information
DDL (data definition language) that is employed for the upkeep of the information structures.
This introductory SQL tutorial can simply cowl information manipulation, as this is often what SQL is employed for many of the time.The most common SQL statements are database queries. the only variety of the syntax for queries is
SELECT columns FROM my_table;
Where columns represents the list of knowledge things within the table that you simply have an interest in with every column separated from successive by a comma. If all columns are needed this will be abbreviated with “*”. thus a really straightforward example would be:- choose * FROM customers;
This query would retrieve each attribute of each client whose details are held within the customers table in our legendary database. The rows selected from the table is restricted with an optional where clause that has the syntax WHERE conditions.
The conditions are a comma separated list of conditions that a record should meet so as to be came back to the user as a part of the results. every condition is outlined as value_or_column operator value_or_column where operator is one in all =,<,>,or <> and price or column is either a worth (e.g.. one or “1″) or the name of a column within the table.
Therefore the only question would be of the shape choose customer_name FROM customers;
Where customers is that the name of the table and customer_name could be a column within the table. this could choose the customer_name column from each row within the table known as customers.
If we tend to solely needed a number of the names we tend to may limit the names selected with a where clause, for example:
SELECT customer_name FROM customers WHERE customer_name > ‘Jones’;
would solely retrieve the department names that will be when Jones alphabetically (e.g. Smith, Weston, Swarbrick, Zachary, King, Loundes, Munden etc.).
Simple Queries To Retrieve information From The Database
Having checked out the essential syntax and a few of easy examples to date during this sql tutorial, let’s move on to make up some additional sophisticated and additional fascinating queries.
We’ve already seen that {the straightforwardst|the solely|the best} question is of the form: choose * FROM the_table; where the_table is any table in our database (actually the_table may be a read or perhaps a sub question however to stay this tutorial simple let’s faux it will only be a table). this question would come all the columns in all rows from no matter table we tend to specify.
