Vinod Sebastian – B.Tech, M.Com, PGCBM, PGCPM, PGDBIO

Hi I'm a Web Architect by Profession and an Artist by nature. I love empowering People, aligning to Processes and delivering Projects.

Advertisements

Creating a Table in SQL

Creating tables is a fundamental aspect of working with databases, especially in SQL (Structured Query Language). The CREATE TABLE statement is used to create tables.

Syntax:

CREATE TABLE table_name (
    column1 datatype,
    column2 datatype,
    column3 datatype,
    ...
);

The CREATE TABLE statement comprises the following components:

  • CREATE TABLE: Indicates the initiation of a new table.
  • table_name: Specifies the name of the table to be created.
  • column1, column2, column3: Denote the names of columns within the table.
  • datatype: Specifies the data type for each column (e.g., VARCHAR, INT, DATE).

Example:

Consider the following example, where a table named users is created with columns for id, name, and email:

CREATE TABLE users (
    id INT,
    name VARCHAR(50),
    email VARCHAR(100)
);

After executing this SQL statement, a new table named users will be generated with the specified columns.

It is vital to define appropriate data types and column constraints when creating tables in SQL. This practice ensures data integrity and enhances the efficiency of your database.

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x