Skip to content Skip to sidebar Skip to footer

How to create a table in sql

     This is the very important and basics of sql server, we can create the table in two way. We can discuss it in the following.

Creating table method
1) Create table using query
2) Create table using options

The below steps are common to both types
1) Open Microsoft SQL server from start menu or icon.

Open Sql server

2) Enter your username and password to login (I am not set any username or password so I can login through windows username and password).

Connect sql server


Create table using query

syntax
create table table_name(col1 datatype(size),col2 datatype(size),etc...)
 After do that common steps, follow the steps
3) Select the database right click and select New Query, now display query window.

New Query in sql server

4) The query window will open and type type following example in the New Query window and press F5 to execute the command.

Example
create table student(name varchar(50),place varchar(20));

Execute sql query

5) The table was created successfully.

Create table using options
     After open and connect with sql server, you need to expand the database, find the Tables folder and right click and select New Table...


Creat table from right click


     In the newly opened window, you can give the column name and data type.

enter column and data type

   
     Finally click save or shortcut key ctrl+s to ask your table name, just enter the table name(student) and press ok to create a table with the name student.

sql table


Table created and now you can check your created table using select query.

select * from student

Post a Comment for "How to create a table in sql"