Create a database
Create DATABASE HQ0128
On primary--The default is the primary filegroup, which can be omitted
(
/*--description of the data file--*/
Name= ' Hq0128_data ',--the logical name of the master data file
Filename= ' D:\HQ0128.mdf ',--the physical name of the master data file
SIZE=5MB,--Initial size of master data file
MAXSIZE=100MB,--Maximum value of master data file growth
filegrowth=15%--the growth rate of the master data file
)
Log on
(
/*--the specific description of the log file, the meaning of each parameter ibid.--*/
Name= ' HQ0128 ',
Filename= ' D:\HQ0128_log.ldf ',
SIZE=2MB,
Filegrowth=1mb
Deleting a database
Use master--set the current database to master for access to the sysdatabases table
Go
if exists (SELECT * from sysdatabases where name= ' HQ0128 ')
Drop Database HQ0128
Go
Create a Table statement
Use HQ0128
Go
if exists (select * from sysobjects where name= ' tb_sinfo ')
drop table Tb_sinfo
CREATE TABLE Tb_sinfo
(
Sidintidentity (primary) key,
sname varchar () NOT NULL,
Xingbiebitnot NULL,
Dianhua varchar (NOT NULL)
)
Go
-Where the column attribute "identity (start value, increment)" means "Sid" is automatically numbered, also known as the identity column
indentity = self-increment increments from one start to 1 per increase
PRIMARY KEY= PRIMARY key
SQL First Lecture 2