Some of the most exciting IT career choices right now and probably in foreseeable future are in database field. With the surge of Big Data and NoSQL databases, the opportunities for DBAs, database developers and BI developers seem endless. This short tutorial is meant as an introduction to Structured Query Language simply known as SQL.
SQL was developed by IBM in the early 70s, and was based on Dr. Codd’s paper, "A Relational Model of Data for Large Shared Data Banks". SQL is a query language used to communicate with Relational Database Management Systems. SQL language has several element types including clauses, expressions, queries, and statements to name a few.
The Data Manipulation Language is the subcategory of SQL commands used to add, update and delete records in a database table.
If you want to add new records to a database table you can use the INSERT SQL statement. Here is an example of inserting data:
INSERT INTO Table1 (Filed1, Field2) VALUES ('Value 1 goes here', 'Value 2 goes here')
To modify existing rows in your table you can use the UPDATE SQL statement. Here is a simple example of updating data with SQL:
UPDATE Table1 SET Field1 = 'New Value goes here' WHERE Field1 = 'Value 1 goes here'
If you need to delete data from a table you can do it like this:
DELETE FROM Table1 WHERE Field1 = 'Value 1 goes here'
Another subcategory of the SQL language commands is the Data Query Language or simply DQL. This subset of SQL is used to retrieve data from a database.
The SQL SELECT command is used to query data from one or multiple database tables and/or views. Here is how to select all records from a table:
SELECT * FROM Table1
The Data Definition Language or DDL is a SQL subset used to deal with database object creation, modification, and deletion.
SQL CREATE is used to create database objects like table. Here is an example:
CREATE TABLE Table1 ( Field1 VARCHAR (255), Field2 VARCHAR (255) )
Here is how to delete a database table:
DROP TABLE Table1
The SQL WHERE clause is used to limit the number of rows that you are retrieving or manipulating. Here is how to select only rows that have the value 'Value 1 goes here' from the table Table1:
SELECT * FROM Table1 WHERE Field1 = 'Value 1 goes here'
The JOIN SQL clause is used to select data from multiple tables and/or views. Here is how to use SQL JOIN, to select data from 2 tables that have common fields:
SELECT Table1.Field1, Table2.Field3 FROM Table1 JOIN Table2 ON Table1.Field1 = Table2.Field1
In conclusion database development is an exciting career field and learning basic SQL is the first step towards your goal to become a great database developer or database administrator.