To help you find the syntax when reading statement syntax, remember the following:
ALTER TABLE
ALTER TABLE is used to update the schema of an existing table.
ALTER TABLE tablename
(
ADD:DROP column datatype [NULL: NOT NULL] [CONSTRAINTS],
ADD:DROP column datatype [NULL: NOT NULL] [CONSTRAINTS],
ADD:DROP column datatype [NULL: NOT NULL] [CONSTRAINTS],
...
) ;
COMMIT
COMMIT is used to write a transaction to the database.
COMMIT [TRANSACTION] ;
CREATE INDEX
CREATE INDEX is used to create an index on one or more columns.
CREATE INDEX indexname
ON tablename ( column, .... ) ;
ON tablename ( column, .... ) ;
CREATE TABLE
CREATE TABLE is used to create new database table.
CREATE TABLE tablename
(
column <datatype_definition> [NULL: NOT NULL] [CONSTRAINTS],
column <datatype_definition> [NULL: NOT NULL] [CONSTRAINTS],
column <datatype_definition> [NULL: NOT NULL] [CONSTRAINTS],
...
) ;
CREATE VIEW
CREATE VIEW is used to create a new view of one or more tables.
CREATE VIEW viewname AS
SELECT columns , ...
FROM tables , ...
[WHERE ...]
[GROUP BY ...]
[HAVING ...] ;
SELECT columns , ...
FROM tables , ...
[WHERE ...]
[GROUP BY ...]
[HAVING ...] ;
DELETE
DELETE deletes one or more rows from a table.
DELETE FROM tablename[WHERE ...] ;
CREATE DATABASE
CREATE DATABASE is used to create a database.
CREATE DATABASE <database_name>
ON [PRIMARY]
[ <filespec> [ , ...n] ]
[ , <filegroup> [ , ...n] ] [ LOG ON { <filespec> [ , ...n] } ] [ FOR LOAD : FOR ATTACH ] <filespec> :: = ( [ NAME = logical_file_name , ]
FILENAME = 'OS'_file_name' [ , SIZE = size ] [ , MAXSIZE = { max_size : UNLIMITED } ] [ , FILEGROWTH = growth_increment ] ) [ , ...n] ]
<filegroup> :: =
FILEGROUP filegroup_name <filespec> [ , ...n]
ON [PRIMARY]
[ <filespec> [ , ...n] ]
[ , <filegroup> [ , ...n] ] [ LOG ON { <filespec> [ , ...n] } ] [ FOR LOAD : FOR ATTACH ] <filespec> :: = ( [ NAME = logical_file_name , ]
FILENAME = 'OS'_file_name' [ , SIZE = size ] [ , MAXSIZE = { max_size : UNLIMITED } ] [ , FILEGROWTH = growth_increment ] ) [ , ...n] ]
<filegroup> :: =
FILEGROUP filegroup_name <filespec> [ , ...n]
DROP
DROP permanently removes database objects (tables, views, indexs, and so forth).
DROP INDEX : TABLE : VIEW indexname : tablename : viewname ;
INSERT
INSERT add a single row to a table.INSERT INTO tablename [ ( columns , ...) ]
VALUES (values , ...) ;
VALUES (values , ...) ;
INSERT SELECT
INSERT SELECT inserts the results of a SELECT into a table.INSERT INTO tablename [ ( columns , ...) ]
SELECT columns , ... FROM tablename , ...
[WHERE ... ] ;
[WHERE ... ] ;
ROLLBACK
ROLLBACK is used to undo a transaction block.ROLLBACK [ TO savepontname ] ; Or ROLLBACK TRANSACTION ;
SELECT
SELECT is used to retrieve data from one or more tables ( or views).SELECT columnname , ...
FROM tablename , ...
[WHERE ... ]
[GROUP BY ... ]
[HAVING ... ]
[ORDER BY ... ] ;
FROM tablename , ...
[WHERE ... ]
[GROUP BY ... ]
[HAVING ... ]
[ORDER BY ... ] ;
UPDATE
UPDATE updates one or more rows in a tables.UPDATE tablename
SET columnname = value , ...
SET columnname = value , ...
[WHERE ... ] ;

0 Comments