SQL SERVER 2017 : PART 3.1 (CREATE TABLE STATEMENT)

  • 6 years ago
Well come to sql server tutorial part 3.1.
Today I will show you how to create and modify table in query editor, Using create table and alter table statement.
In part 3, I have talked about table, how to create it graphically and data types.

In previous tutorial we have created customer table.
Now I am going to create same table using query editor.


USE TEST_DB

CREATE TABLE Customer1
(
[CustomerID] [int] NOT NULL,
[FirstName] [varchar](50) NULL,
[LastName] [nchar](10) NULL,
[BirthDate] [date] NULL,
)

First login to sql server management studio.
Click new query.
Type use database name.
Under that database the table will be created.
For this tutorial test db is our database name.

Now type create table and table name customer table.
Press enter then type opening and closing first bracket.
In between these bracket type column name data type and constraint.
Every column must be separated by a comma sign.

Click execute.
Refresh database to view the newly created table.

In practical environment you may need to modify table.
In sql, it is called alter table.

Now I will show you how to add and delete column from an existing table.

Type alter table and customer table as table name.
Then type add, column name and data type.
Click execute.
Select table.
Click refresh.
Expand to view newly added column.

Now I will show you how to delete a column from a table.
Type drop column and column name.
Then click execute.

COLUMN NAME joining date has been deleted.
That’s all for today. Please subscribe to my channel. Don’t forget to comment and like or dislike.

Recommended