Create (SQL)

From Wikipedia, the free encyclopedia

A CREATE statement in SQL creates an object inside of a relational database management system (RDBMS). The types of objects that can be created depends on which RDBMS is being used, but most support the creation TABLEs, INDEXes, USERs, and DATABASEs. Some systems (such as PostgreSQL) allow CREATE and other DDL commands to occur inside of a transaction and thus be rolled back.

[edit] CREATE TABLE

Perhaps the most common CREATE command is the CREATE TABLE command. The typical usage is:

CREATE [TEMP[ORARY]] TABLE [table name] ( [column definitions] ) [table parameters].

Column Definitions: A comma-separated list consisting of any of the following

  • Column definition: [column name] [data type] {NULL | NOT NULL} {column options}
  • Primary key definition: PRIMARY KEY ( [comma separated column list] )
  • CONSTRAINTS: {CONSTRAINT} [constraint definition]
  • RDBMS specific functionality

For example, the command to create a table named employees with a few sample columns would be:

CREATE TABLE employees (   
   id            INTEGER   PRIMARY KEY,
   first_name    CHAR(50)  null,
   last_name     CHAR(75)  not null,
   date_of_birth DATE      null
);

[edit] See also

Topics in database management systems (DBMS)view  talk  edit )

Concepts
Database • Database model • Relational database • Relational model • Relational algebra • Primary key, Foreign key, Surrogate key, Superkey, Candidate key • Database normalization • Referential integrity • Relational DBMS • Distributed DBMS • ACID

Objects
Trigger • View • Table • Cursor • Log • Transaction • Index • Stored procedure • Partition

Topics in SQL
Select • Insert • Update • Merge • Delete • Join • Union • Create • Drop

Implementations of database management systems

Types of implementations
Relational • Flat file • Deductive • Dimensional • Hierarchical • Object oriented • Temporal • XML data stores

Components
Query language • Query optimizer • Query plan • ODBC • JDBC

Database products

Apache Derby • Berkeley DB • Caché • DB2 • DBase • Filemaker Pro • Firebird • H2 • Helix • Informix • Ingres • InterBase • Microsoft Access • Microsoft SQL Server • MySQL • NonStop SQL • OpenLink Virtuoso • OpenOffice.org Base • Oracle • Oracle Rdb • Paradox • Perst • PostgreSQL • SQLite • Sybase IQ • Sybase • Teradata • Visual FoxPro


Other: Object-oriented (comparison) • relational (comparison)

In other languages