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.
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).
Create table using query
syntax
3) Select the database right click and select New Query, now display query window.
4) The query window will open and type type following example in the New Query window and press F5 to execute the command.
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...
In the newly opened window, you can give the column name 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.
Table created and now you can check your created table using select query.
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.
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).
Create table using query
syntax
create table table_name(col1 datatype(size),col2 datatype(size),etc...)
After do that common steps, follow the steps3) Select the database right click and select New Query, now display query window.
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));
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...
In the newly opened window, you can give the column name 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.
select * from student
Post a Comment for "How to create a table in sql"