SQL syntax

Database Tables
A database usually contains one or more tables. Each table is identified by a name (eg "customers" or "orders"). A table contains records (rows) with data.
The following example is a table named "Persons":
Id LastName FirstName Address City
1 Adams John Oxford Street London
2 Bush George Fifth Avenue New York
3 Carter Thomas Changan Street Beijing
The above table contains three records (each for a person ) and five columns (Id, Last Name, First Name, Address, and City).
SQL Statements Most of the work
you need to perform on the database is done by SQL statements.
The following statement selects data from the LastName column from the table:
SELECT LastName FROM Persons
The result set looks like this:
LastName
Adams
Bush
Carter
In this tutorial, we'll walk you through various SQL statements.
Important It
is to remember that SQL is not case sensitive!
Semicolon after SQL statement?
Some database systems require a semicolon at the end of each SQL command. Semicolons are not used in our tutorials.
A semicolon is a standard way of separating each SQL statement in a database system so that more than one statement can be executed in the same request to the server.
If you are using MS Access and SQL Server 2000, you do not have to use a semicolon after each SQL statement, although some database software requires it.
SQL DML and DDL
SQL can be divided into two parts: data manipulation language (DML) and data definition language (DDL).
SQL (Structured Query Language) is a syntax for executing queries. But the SQL language also includes syntax for updating, inserting, and deleting records.
Query and update instructions form the DML part of SQL:
SELECT - Get data from a database table
UPDATE - Update data in a database table
DELETE - Delete data from a database table
INSERT INTO - Insert data into a database table
SQL's Data Definition Language ( DDL) section gives us the ability to create or delete tables. We can also define indexes (keys), specify links between tables, and impose constraints between tables.
The most important DDL statements in SQL:
CREATE DATABASE - create a new database
ALTER DATABASE - modify a database
CREATE TABLE - create a new table
ALTER TABLE - alter (alter) a database table
DROP TABLE - drop a table
CREATE INDEX - creates an index (search key)
DROP INDEX - drops an index

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326563773&siteId=291194637