CREATE

Definition:

Create something in the database system.

Command Syntax:

CREATE DATABASE database_name;
  • create a new database called database_name
CREATE TABLE table_name(
field1_name data_type [constraint(s)],
field2_name data_type [constraint(s)],
field3_name data_type [constraint(s)],
...
fieldN_name data_type [constraint(s)],
[constraint],
[constraint],
...
[constraint]
);
  • create a new table called table_name with fields
  • every field has a data type and optional constraint(s)
  • every table has fields and optional constraint(s)
CREATE VIEW view_name AS 
SELECT ... # same as SELECT - SQL statement
;
  • create a new view of virtual table called view_name with a SELECT - SQL statement
  • view name could not duplicate with table name
CREATE OR REPLACE VIEW view_name AS
SELECT ... # same as SELECT - SQL statement
;
CREATE INDEX index_name ON table_name(field_name);
  • index a field of a table called index_name
  • allow to perform binary search on the indexed field to enhance the speed of the data retrieval process 

'Everything starts with a CREATE.'By secondary 6 student

Comments