Monday, February 8, 2016

SQL Create Table


SQL CREATE TABLE
The CREATE TABLE statement is used to create a table in a database to stored data.
Tables are organized into rows and columns; and each table must have a name.
SQL CREATE TABLE Syntax
CREATE TABLE tablename
(
columnname1 datatype(size) [null | Not Null],
columnname2 datatype(size) [null | Not Null],
columnname3 datatype(size) [null | Not Null],
....
);
Parameters
tablename
The name of the table that you wish to create.
columnname1, columnname2
The columns that you wish to create in the table. Each column must have a datatype. The column should either be defined as NULL or NOT NULL and if this value is left blank, the database assumes NULL as the default.
CREATE TABLE employees
( employeeid INT NOT NULL,
  lastname VARCHAR(50) NOT NULL,
  firstname VARCHAR(50), 
  Address varchar(200)
  areaPin bigint
  );
  1.     Column name employeeid is numeric column and can’t be null
  2.        Lastname, firstName,Address is varchar column.
  3.      AreaPin is numeric column.



No comments:

Post a Comment