Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in SQL by (55.6k points)

Can anyone tell me how to create table in SQL?

1 Answer

0 votes
by (119k points)

Creating the table in SQL involves naming the table, defining the fields and data types, and also defining key constraints for the fields.

The following is the example to create a customer table in SQL:

Create TABLE customers (

Customer_ID                INT                  NOT NULL,

Customer_NAME        VARCHAR (15) NOT NULL,

Customer_AGE            INT                     NOT NULL,

SALARY                         DECIMAL (18,2)

PRIMARY KEY (ID)

);

In the above example, Create table is a keyword that tells the database that you want to create a table. After that in brackets, Custmer_ID, Customer_NAME  Customer_Age, and Salary are the fields of the table. NOT NULL and PRIMARY KEY are the key constraints that you are keeping constraints for the fields.

If you want to learn SQL, you can sign up for this SQL certification program by Intellipaat.

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
asked Apr 22, 2020 in SQL by Sudhir_1997 (55.6k points)
0 votes
1 answer

Browse Categories

...