The CREATE TABLE statement is used to create a table in a database.
Syntax:
CREATE TABLE table_name
(
column_1 data_type(size),
column_2 data_type(size),
column_3 data_type(size),
);
Example:
CREATE TABLE State
(
StateName varchar(100),
CountryCode varchar(100),
CityCode varchar(255),
isCanceled bit default 0 not null
);
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEivCG-KdwxZUl3iTnLpNrpZc-f4bwK5lLKit1WTNLn8WH_3PO2WTR2KtZXE4xWC__XvXtcAPc4VrwhFbcvyAea6EVB1qDO2Z5uImOTen9lRx4tyNgW9D8fz6t7PhPbOJYjPnUTL_UPigl9y/s400/sql+create+table+.png)
Select Table.
select * from state
SQL CREATE TABLE with Identity Statement.
Auto increment allows a unique number to be generated when a new record is inserted into a table.
By default starting value for AUTO_INCREMENT is 1.
Example:
CREATE TABLE StateNew
(
Id int identity(1,1),
StateName varchar(100),
CountryCode varchar(100),
CityCode varchar(255),
isCanceled bit default 0 not null
);
Insert Records.
insert into statenew (statename,countrycode,
citycode,iscanceled)values('TamilNadu','1','3',0)
Select Table.
select * from statenew
Result:
0 Comments