HOW TO CREATE A TABLE IN SQL

There are mainly two methods for creating a table in SQL. They are as follows:

  • Manually Writing the Code.
  • Making use of an Icon.

Manually Writing the Code

  1. Make use of the CREATE TABLE statement.
  2. Define your table name.
  3. Define your column names and character types e.g. INT, VARCHAR.
  4. Apply certain constraints to your columns when necessary such as AI (Auto Increment), PK( Primary Key) used for the column that serves as the primary key.
Manual writing of code for Table creation.

Making use of an Icon

  1. In the Schema section on the left, locate the database in which you want to create the table.
  2. Click on the database name then right click the table section and select “Create Table” from the dropdown menu. Or navigate the left top corner to find an icon that does the same function.
  3. A box will pop up.
  • Table Name: Enter the name of your new table.
  • Columns: Add columns by entering names, selecting data types (like INT, VARCHAR, etc.), and adding constraints such as PRIMARY KEY or NOT NULL using checkboxes.
  1. After configuring the table structure, click “Apply”.
  2. A preview of the SQL statement (which you don’t need to write manually) will be shown. Click “Apply” again to execute the command.
  3. Your table will now be created in the database.

Leave a Comment

Your email address will not be published. Required fields are marked *