What is Table?

The table is a collection of organized data in the form rows and columns. A table is the convenient representation of relations in DBMS. It is a simple form of storage.

 

Note: A table has to be specified with specific number of columns and it can have any number of rows

 

Example of a Table is as follows:

  STUDENT

NameAgeCourse
Nithin22CSE
Bhaskar23MECH
Paresh21EEE

 

Here ‘STUDENT’ represents the Name of the Table. Name, Age, Course represents the column names. The combinations of multiple columns of data form a row. A row contains data relates to one in different columns.

 

In the next tutorial, we are going to learn how to create a table, how to insert data into a table, how to alter, delete, drop, rename, truncate the table.

 

SQL CREATE TABLE

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

When you create a table, you should name the table and define column names with its data type.

 

The syntax of CREATE TABLE is as follows

CREATE TABLEtablename

(Column_name1 data type (size),

column_name2 data type(size),

column_name3 data type(size),

….

);

 

The table name specifies the name of the table

The Column_name parameter specifies the column name.

The data type Parameter here specifies what type of the data the column can hold (e.g. varchar, integer, date, etc..,)

The size parameter specifies the maximum length of the column of the table.

 

Example:

CREATE TABLEStudent

(

StudentIDInt,

Student_NameVarchar(255),

Address varchar(255),

City varchar(255)

);

 

And the empty table created will look as below,

 

StudentIDStudent_NameAddressCity
    

 

Here, The StudentID stores integer values Student_name, Address, City store character values into it and the maximum length is 255 characters.

After creating the table SQL will display the message that table is created or you can view it by yourself by using DESC command as

 

DESC Student;