SQL Server tutorial part 2 - DDL (Data Definition Language) - Create Table

The CREATE TABLE statement is used to create a new table in a database. The following constraint can be applied when creating a table:
  • NOT NULL - Ensures that a column cannot have a NULL value
  • UNIQUE - Ensures that all values in a column are different
  • PRIMARY KEY - A combination of a NOT NULL and UNIQUE. Uniquely identifies each row in a table
  • FOREIGN KEY - Uniquely identifies a row/record in another table
  • CHECK - Ensures that all values in a column satisfy a specific condition
  • DEFAULT - Sets a default value for a column when no value is specified
  • INDEX - Used to create and retrieve data from the database very quickly


Using script


Create temporary table




Using GUI

In SQL server management studio expand the database created and right click on "TABLES" from the context menu select NEW > TABLE


Create your table and right click on the column that you want to make it as a primary key constraint and from the context menu select Set Primary Key




In the Column property panel, search for "Identity Specification" expand it and change option "Is Identity" from no to yes



Use Ctrl + S on your keyboard to save the table or click the save icon

Please donate and support at https://www.paypal.me/Rajcoomar

Comments

Popular posts from this blog

C# Windows Form : PetCare

Fake Call Android Application

Car Wash System vb.net