Simple, as not a good program, it is easy to forget the SQL statement:
Use master
Go
--Determine if the database exists
If exists (select *from sysdatabases where name= ' database name ')
Drop database name
Go
--Create a database
Create DATABASE name
On primary
(
Name= ' wydb_test_data ',--database logical name
Filename= ' D:\SQL\WYDB_test_data.mdf ',--database physical file name
SIZE=20MB,--Database Initial Size
filegrowth=10mb--database File Increment
)
Log on
(
Name= ' Wydb_test_log ',--database logical name
Filename= ' D:\SQL\WYDB_test_log.ldf ',--database physical file name
SIZE=10MB,--Database Initial Size
filegrowth=5mb--database File Increment
)
Go
--Using the database
Use database name
--Determine if the table name exists
if exists (SELECT * from Sysobjects where name= ' table name ')
Drop Tablet_user
Go
--Create TABLE T_user | User table
CREATE TABLE Table name
(
Idintidentity (primary) key,--user ID
Usernamevarchar (uniquenot) null,--user name
Passwordvarchar () NOT null,--user login password
Phonenchar (one),--constraint mobile phone number is 11 digits
Birthdaysmalldatetime,--User's birthday
Classintdefault 1,--User level (default is level 1)
Imagehearturlvarchar (max),--user picture
Createtimesmalldatetimedefault getdate (),--User creation time
Isadminbitdefault 0--is administrator 0: No 1: Yes
)
Go
SQL Server simply creates a database