Structured Query Language
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. We can use SQL Queries to add data, remove data, or view data in the database.
Examples[change | change source]
This is a simple SQL Query which is used to show a column named 'my_column' of the data table named 'my_table'.
1 SELECT my_column FROM my_table; 2 example : SELECT name FROM Employee; 3 12 4 123 5 1234
"select", 'name', 'firstname'najeem
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 they 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 accidentally put letter data into it) and it will break.