Simple introduction to SQL
Introduction
SQL (Structured Query Language) is a common tool for retrieving data from relational databases such as MySQL, SQL Server, MariaDB, and PostgreSQL. Together with R and Python, SQL is one of the top skill in mastering Data Science.
What is SQL?
SQL stands for Structured Query Language, it’s a language for manipulating and talking about data in databases but was originally called SEQUEL for Structured English Query Language.
SQL is the standard language for Relational Database System and all the Relational Database Management Systems (RDMS) like MS Access, Microsoft Transact-SQL or T-SQLMySQL, SQLite, Oracle, Postgres, SQL Server, Sybase and Informix.
What is Syntax?
SQL is followed by a unique set of rules and guidelines called Syntax.
We need to understand what are the basic parts of a statement to start building SQL statements. To get an answer from a database or to make any change to database is called a statement.
All the statements start with any of the keywords like SELECT, INSERT, UPDATE, DELETE, ALTER, DROP, CREATE, USE, SHOW and all the statements end with a semicolon (;).
Statement.
What is a Statement?
A statement is made up of Clauses and Clauses are the basic components of statements that make up the whole and these clauses are constructed out of keywords, which tell to the the database to take some action.
Note: SQL is case insensitive which means SELECT and select have same meaning in SQL statements.
Most Important Commands for daily use
CREATE DATABASE => To create a new database
CREATE TABLE => To create a new table
INSERT INTO => To insert new data into a database
SELECT => To extract data from a database
UPDATE => To update data in a database
DELETE => To delete data from a database
ALTER DATABASE => To modify a database
ALTER TABLE => To modify a table
DROP TABLE => To delete a table
You can download this Class table and try yourself.
class.xlsx
Download XLSX • 10KB
If want to select all columns from a table we can use an asterisk (*) following a SELECT to select all columns.
SELECT * FROM Class;
If require only Name and Age columns then we can use those particular columns in SELECT clause.
SELECT Name, Age FROM Class;
Happy Learning !!! :)