Create Table in SQL

How to create SQL Table:

As we know that table is the collection of rows and columns.In ralational database managenemt system we arrange all data into tables and make relation between them.For learn Sql database.work of Sql database. visit this link.



In SqlDatabase create table:

Syntax of Query
CREATE TABLE table_name
(
column_name1 data_type(size),
column_name2 data_type(size),
column_name3 data_type(size),
....
);

You can also create table without Query written, you can create using GUI of SQL management system.

Step 1: First right click on data base name.
Step2: Choose table menu and right click here.

Create Sql Table
Create Sql Table

Step3: click new table menu and create table.

Define table in sqldata base
Define table in sqldata base

Step4: define all columns then save table and give the name of table.

Table with primary key by Sql Query :

CREATE TABLE table_name
(
column_name1 data_type(size) IDENTITY(1,1) NOT NULL,
column_name2 data_type(size),
column_name3 data_type(size),
....
);


Example of Sql Table with primary key:

Here we make a table named Login_Master and take five columns. LoginID, RegID, UserName, Password, Active.
CREATE  Login_Master (
                [LoginID] [int] IDENTITY(1,1) NOT NULL,
                [RegID] [int] NULL,
                [UserName] [varchar](50) NULL,
                [Password] [varchar](50) NULL,
                [Active] [bit] NULL,
 CONSTRAINT [PK_Alumina_Login_Master] PRIMARY KEY CLUSTERED ([Aumina_LoginID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]) ON [PRIMARY]



Other Related Post :

Comments