SQL Create Table

Create a Database Table with Columns

Tables are organized into rows and columns and must have a name.

Create table Syntax:
MySQL, Oracle, SQL server, PostgreSQL:
CREATE TABLE table_name
(column_name datatype [NULL | NOT NULL]
[, column_name datatype [NULL| NOT NULL] ]...);
This is a short version of the syntax. Each RDBMS have many other own options to this CREATE TABLE statement.
Create table example:
CREATE TABLE Customer (
 CUSTOMER_ID INT NOT NULL,
 FIRST_NAME VARCHAR(20) NULL,
 LAST_NAME VARCHAR(20),
 EMAIL VARCHAR(30) NULL
 );
To create a table you must at least:
  1. Start with, "Create table" and then the table name (here Customer).
  2. Type a open parenthesis as a start to include columns.
  3. For each column write the name first.
  4. Follow by a space and then the data type.
  5. Optional write the keywords NULL or NOT NULL whether the column require a value or can be null (The default is NULL).
  6. End the included columns and table definition with a Closing parenthesis and a semicolon.
Prev. in menu SQL/Definition/TableColumns.php Next in menu
Prev. in menu SQL/Definition/TableColumns.php Next in menu
© 2010 by Finnesand Data. All rights reserved.
This site aims to provide FREE programming training and technics.
Finnesand Data as site owner gives no warranty for the correctness in the pages or source codes.
The risk of using this web-site pages or any program codes from this website is entirely at the individual user.