What is SQL?
SQL is a database computer language designed for the retrieval and management of data in a relational database. SQL stands for Structured Query Language. Although SQL is an ANSI/ISO standard, there are different versions of the SQL language. All versions support at least the major commands (such as SELECT, UPDATE, DELETE, INSERT, WHERE) in a similar manner.
SQL is designed for managing data held in a relational database management system (RDBMS). The data in RDBMS is stored in database objects call tables. A database table is a collection of related data entries which consists of rows and columns. Different tables contain information about different types of things. Each row in a database table represents one instance of the type of object described in that table.
A row is also called a record. For instance: In a table animals, the rows would be dog, cat, cow etc. The column in a table are the set of facts that we keep track of about that type of object. A column is also called an attribute or a field. In a table animals, the columns would be name, number of legs, weight, height etc.
The data below is referred to as rows. An example of the table animals where the column Weight is not a required column. Then in the row Cat under column Weight would be NULL. The column with a NULL value is the one that has been left blank during a record creation.
Now let’s look at some common SQL commands. The first one is an INSERT INTO statement and it is used to insert new rows in a table. The second one is a SELECT statement and it is used to select data from one or more tables. The data returned is stored in a result table, also called the result-set.
We will work with only one table, called skills, whose structure looks like the image above. The table skills contains columns id and name. The column id (integer) has the primary key constraint which uniquely identifies each row in a table (must be unique and can’t be null) and the column name (text — usually the string/text data type that requires a length) has a maximum length of 100 characters.
Above we are inserting data into our database table. We don’t have to provide an id column because the database will generate it automatically (auto-increment allows a unique number to be generated automatically when a new record is inserted into a table).
We can also insert multiple values at the same time.
If you are inserting values for all the columns of the table, you don’t need to specify the column names after the table name, but make sure the order of the values is in the same order as the columns in the table.
Lastly if you want to select all the columns from the table us the asterisk ‘*’ sign.