How to Write SQL Query to Create Table

If you are familiar with Excel then you will know how a table in RDBMS works, and data stored in Tables. You can say the next version of Excel is RDBMS Table.

What is SQL Table

This post is useful for you to start learning about Table and accessing it using SQL. An SQL table consists of scalar (single-value) data arranged in columns and rows.

Relational database tables Components

  1. A unique table name
  2. Unique names for each of the columns in the table
  3. At least one column
  4. Data types, domains, and constraints that specify the type of data and its range of values for each column in the table
  5. A structure in which data in one column of the table has the same meaning in every row of the table
  6. Zero or more rows that represent physical or logical entities

How to Name a Table

When naming a table, bear in mind that no two tables you create can have the same name. However, table names in the SQL database need be unique only among all of the tables created (or owned) by an individual user.

Also read: 32 Complex SQL queries to instant knowledge

As such, if two users—SONU and KIRI, for example—were to create tables in an SQL database, both of them could create a table named Stocks.

However, neither of them could create two tables named Stock in the same schema.

With this you will know table names and how the DBMS uses the owner name and schema name to make the names unique across all of the tables in the database.

The important thing to know is that you must give your table a name, and you don’t have to worry about what other people have named their tables.

When selecting a table name, analyze the columns you plan to include in the table, and use a name that summarizes the table’s contents.


Author: Srini

Experienced software developer. Skills in Development, Coding, Testing and Debugging. Good Data analytic skills (Data Warehousing and BI). Also skills in Mainframe.