What is SQL
SQL stands for structured query language. It is used to query the relational databases. Since the name is saying the structured means it handles structured data.
What is structured data
Here structured data means a data which is in tabular format. And the data that have some relations between data is called relational data.
You can query structured data residing inside relational database management system. Relational database management system is a management system which stores and handles the data. Data volume could be too much like in GB, TB,PB. RDMS(Relational database management system) can handle this much of volume.
There are lot of RDBMS in the market like Oracle, SQL server, MYSQL and Postgres etc. Here MYSQL and Postgres both are open source.
Previously SQL was called structured english query language (SEQUEL) . Later it was renamed as structured query language(SQL). Many people call it SEQUEL and many call it SQL. So it's up to you what you want to call it.
A brief History of SQL
1970 − Dr. E. F. Codd of IBM is known as the father of relational databases. He described a relational model for databases.
1974 − Structured Query Language appeared.
1978 − IBM worked to develop Codd's ideas and released a product named System/R.
1986 − IBM developed the first prototype of relational database and standardized by ANSI. The first relational database was released by Relational Software which later came to be known as Oracle.
How to write SQL and how to fetch data
First you need to decide which RDBMS you are going to install on your system. I would recommend using postgres which is open source or SQL server which is not open source but you can download it's free version. Microsoft is developer of SQL server.
Now I am assuming that you have downloaded the RDBMS. If not then you can practice on any online platform which provide you sql editor.
Suppose I have table EMPLOYEE, which has three columns name, age, city.
Name | Age | City |
Suraj | 25 | Banglore |
Mohit | 26 | Chennai |
Rahul | 27 | Lucknow
|
I want to fetch all records inside this table, so I will write below query:
SELECT * FROM EMPLOYEE;
Here you are query data then you need to write SELECT , * means all columns (Name,Age,City) ,write from keyword then table name. In this case table name is EMPLOYEE.
So above query will give you all records from the table. If I want to select only name then I need write only Name column in my query like Below:
SELECT Name FROM EMPLOYEE;
Similar for Age and City as well:
SELECT Age FROM EMPLOYEE;
SELECT City FROM EMPLOYEE;
Suppose I want to display all details about Suraj then I'll write below query:
SELECT * FROM EMPLOYEE WHERE NAME = 'Suraj'
Name | Age | City |
Suraj | 25 | Banglore |
You can use a wild card for search but there is a lot to cover on SQL. I suggest to read more on basics of SQL to get started.
No comments:
Post a Comment