Jump to content

Structured Query Language

From Simple English Wikipedia, the free encyclopedia
Revision as of 15:22, 26 February 2015 by 138.162.140.54 (talk) (Put quotes around the second "42".)

Structured Query Language (SQL) is a language used to view or change data in databases. The sentences used in this language are called SQL Queries. If we want to add data to the database in a computer, or to remove data from the database, or to just view the data in the database, we can use SQL Queries.

Examples

This is a simple SQL Query which is used to show a column named 'my_column' of the data table named 'my_table'.

SELECT my_column FROM my_table;

Here is an example of inserting information into a table called 'people.' The query first names the table, people, then the columns that data is going to be inserted into, (first name, last name, age, and favorite food), and the data that is going into the columns. SQL knows which data goes into which column by the order the columns are listed.

INSERT INTO people (first_name, last_name, age, favorite_food) VALUES ("Bob", "Page", "42", "Hamburgers");

Here is an example of the same thing, but the columns aren't listed. If this is done, SQL will insert the data in the order the columns are listed.

INSERT INTO people VALUES ("Bob", "Page", "42", "Hamburgers");

However, if a programmer does the query in the method that does not name the columns, they need to be careful, because if the columns are not in the order that the listed the data, they could put the wrong type of data in the wrong column, or perhaps the column they put data into may want a different type of data (for example, a column might want number data, but someone might accidently put letter data into it) and it will break.