Create Table in SQL

Price: INR 8,999.00
Price: INR 15,999.00
Was: INR 16,999.00

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

While creating the Table, you must specify the Table Name, Column Names, column Data Types and column size.

 

SQL Syntax :

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

 

  • The column_name parameters specify the names of the columns of the table.

  • The data_type parameter specifies what type of data the column can hold (e.g. varchar, integer, decimal, date, etc.).

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

 

SQL Create Table Example

In this example, We will see how can we create the Table in Database. Let’s create the table named EMPLOYEE that contains four columns : First_name, Last_name, Salary. Department.

 

SQL > CREATE TABLE Employees (
First_Name varchar2(50),
Last_Name varchar2(50),
Salary int,
Department varchar2(100) );

 

This will create the Employees table, which contains four fields. First_Name, Last_Name and Department columns will contain the character values and Salary field will contain the integer values.

 

0 Comment

Leave a Reply