I. Creating a database statement
Create DATABASE name
On primary--The default is the primary filegroup, which can be omitted
(
/*--description of the data file--*/
Name= name ' Hq0128_data ',--the logical name of the main data file
Filename= ' d:\ database name. 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= ' database name ',
Filename= ' d:\ database name _log.ldf ',
SIZE=2MB,
Filegrowth=1mb
)
Second, delete the database statement
Use master--set the current database to master for access to the sysdatabases table
Go
if exists (SELECT * from sysdatabases where name= ' database name ')
Drop database name
Go
Iii. Creating a Table statement
Use database name
Go
if exists (SELECT * from sysobjects where name= ' database name ')
DROP table Name
CREATE TABLE Table name
(
SidintIdentity(primary) key,//Set 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
1. Add a data statement to the table
Insert into table name (column name, ...). Values (column value, .....) )
2. Delete data from the table
Delete from table name where conditional expression
3. Modify the data in the table
Update table name set table name = "expression" Where condition expression
4. Query statements
Select (.../* Query for what */) from (.../* from what */) where (.../* what conditions */)
Iv. Deleting a table statement
DROP table Name
20150504 the creation and deletion of SQL database in tables