What is SQL?
SQL (Structured Query Language) is used to perform operations on the records stored in database like creating and modifying tables, updating records, deleting records, views, functions etc.
Structured Query Language is just a query language, it is not a database or tables. To perform SQL queries, first you need to install any database for example Oracle, MySQL, MongoDB, PostGre SQL, SQL Server, DB2, SQLite etc.
SQL commands are the set of instructions, coded into SQL statements, which are used to communicate with the database to perform specific tasks, functions and queries with particular data.
SQL commands can not be used only for searching from the database but also to perform various other functions like, for example, you can create tables, add data into tables, or modify data, drop or delete the table. These are grouped into four major categories depending on their functionality:
- Data Definition Language (DDL) – DDL SQL commands are used for creating, modifying, and dropping the structure of database objects(dbo). DDL commands are CREATE, ALTER, DROP, RENAME, and TRUNCATE.
- Data Manipulation Language (DML) – These SQL commands are used for storing, retrieving, modifying, and deleting data from a database. These DML commands are: SELECT, INSERT, UPDATE, and DELETE.
- Transaction Control Language (TCL) – These SQL commands are used for managing changes affecting the data. It is also used for data integrity. TCL commands are COMMIT, ROLLBACK, and SAVEPOINT.
- Data Control Language (DCL) – DCL SQL commands are used for security purpose. These commands are GRANT and REVOKE.
CREATE, DROP and RENAME DATABASE
CREATE, DROP, DELETE, RENAME, TRUNCATE and COPY TABLE
SELECT statement with UNIQUE, DISTINCT, AS and IN keywords and first(), last(), top(), sum(), random() and count() functions.
INSERT INTO, INSERT SELECT and INSERT multiple rows.
UPDATE statement, update with JOIN and update DATE.
DELETE TABLE, DELETE One Row, DELETE all rows, DELETE VIEW, DELETE database, DELETE duplicate rows and DELETE with INNER JOIN.
INNER JOIN, OUTER JOIN, LEFT OUTER JOIN, RIGHT OUTER JOIN and SELF JOIN.
SQL keys are primary key, foreign key, composite key, alternate key and unique key.
For more Database Design