sql create table statement

SQL Advance

homeBack

Next

SQL CREATE TABLE Statement

  • The CREATE TABLE statement is used to create a table in a database.

  • SQL CREATE TABLE Syntax

    CREATE TABLE table_name
    (
    column_name1 data_type,
    column_name2 data_type,
    column_name3 data_type,
    ….
    )
     “

    The data type specifies what type of data the column can hold. For a complete reference of all the data types available in MS Access, MySQL, and SQL Server

  • SQL CREATE TABLE Example

    we want to create a table called “emp” that contains five columns: S.no, Name2, Name1, and City. We use the following CREATE TABLE statement: 

    CREATE TABLE emp
    (
    S.no int,
    Name2 varchar(255),
    Name1 varchar(255),
    City varchar(255)
    )
     “

    The empty “emp” table will now look like this:

    S.no Name2 Name1 City

    The empty table can be filled with data with the INSERT INTO statement.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s