SQL – CREATE Command (to create Database and Table)

SQL CREATE Command: Here, we will figure out how to make a database and a table utilizing CREATE order in SQL?

Make is a DDL order used to make table or database in SQL.

1. Making Database

Another Database can be made in SQL by utilizing the CREATE DATABASE articulation. For example to make another Database of name ‘MyDatabase’ following proclamation ought to be executed.


On the off chance that a Database of name MyDatabase doesn’t exist it will make another database else it will show an error.

ERROR 1007
Can’t create database ‘MyDatabase’ ; database exists

What’s more, Database won’t be made except if you change the name of the Database.

2. Making Table

Another Table can be made in SQL by utilizing the CREATE TABLE articulation. Another table can be made by utilizing the following syntax.

CREATE TABLE table_name
(column_name  datatype [constraint],
 column_name  datatype [constraint],
 column_name  datatype [constraint],...);


column_name is the name of the segment the datatype is the property that determines what sort of information a segment can store Following are the information types in SQL

  • char(size)
    • A series of characters of length size. size can have the most extreme value of 255 characters.
  • date
    • It stores date
  • varchar(size)
    • A string of character of length size.
  • numeric(maxsize)
    • Number with a most extreme number of digits maxsize.
  • Limitations
    • limitations are the principles for the section.
  • Following are the potential values of a limitation can have:
    • NOT NULL
      • The segment must have some value can’t be left vacant.
    • Remarkable
      • No two values can be the same inside this segment.
    • Essential KEY
      • Each record in the table is particularly recognized by this section.

For example: to make a table understudy with segments name, roll no, age, date of birth, the following proclamation should be executed.

( roll_no numeric(15) PRIMARY KEY NOT NULL,
name varchar(25),
age numeric(2), 
dob date);

Leave a Comment

error: Alert: Content is protected!!