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] ]...);
Create table example:
CREATE TABLE Customer ( CUSTOMER_ID INT NOT NULL, FIRST_NAME VARCHAR(20) NULL, LAST_NAME VARCHAR(20), EMAIL VARCHAR(30) NULL );
- Start with, "Create table" and then the table name (here Customer).
- Type a open parenthesis as a start to include columns.
- For each column write the name first.
- Follow by a space and then the data type.
- Optional write the keywords NULL or NOT NULL whether the column require a value or can be null (The default is NULL).
- End the included columns and table definition with a Closing parenthesis and a semicolon.
© 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.