Basics of SQL Statement
Most of action you need to perform with sql statement, for example you need to retrieve data from a table tutorial, you need to use following statement.
you will retrieve following result.
| ID | Category | Author | Tutorial |
| 1 | PHP | Hassan | what is php |
| 2 | MySql | James | what is sql |
| 3 | Ajax | Andrew | what is ajax |
| 4 | ASP | Micheal | ASP Introduction |
| 5 | C++ | Dhanraj | C++ Basics |
notice in this tutorial id, category, author, tutorial are columns every column has its own records
Semicolon after sql statement
Some database systems require a semicolon at the end of each SQL statement. Semicolon is the standard way to separate each SQL statement in database systems that allow more than one SQL statement to be executed in the same call to the server.
SQL DML and DDLSQL contains two parts:
- DML: The Data Manipulation Language
- DDL: Data Definition Language
The query and update commands form the DML part of SQL:
- SELECT - retrieves data from a table in database
- UPDATE - updates/modifies data in a database
- DELETE - deletes records from a database
- INSERT INTO - inserts new records into a database
The DDL is used to be create or delete tables/database. It also define indexes, primary keys, foreign keys, specify links between tables, and impose constraints between tables. The most important DDL statements in SQL are:
- CREATE DATABASE - creates a new database
- ALTER DATABASE - modifies a database
- CREATE TABLE - creates a new table
- ALTER TABLE - modifies a table
- DROP TABLE - deletes a table
- CREATE INDEX - creates an index (search key)
- DROP INDEX - deletes an index