UseMaster--using master PermissionsCreate DatabaseE_market--Create a new database on Primary--Specify the master data file with only one(Name='E_market_data',--The main file logical name, _data refers to the file type, here is the data file typeFileName='F:\sql Practice \e_market_data.mdf' , --physical file name, given the storage path and file formatSize=5MB,--File Initial SizeFileGrowth= the%--growth rate of documents)Log on--Specify a log file with at least one(Name='E_market_log',--log file logical filename, _log indicates the file type, here is the log file typeFileName='F:\sql Practice \e_market_log.ldf', --log file physical file name, storage path, and finally the format to be marked. Size=1MB,--Initial SizeMaxSize=10MB,--Maximum ValueFileGrowth=1MB--Growth rate) UseE_marketCreate TableUserInfo--Create a table with a table name of Userinfor(--Create column format column name + data type +[Property]Useridvarchar( -)Primary Key,--primary key to set primary key, primary key cannot be empty by defaultUserpwdvarchar( -) not NULL, UserNamenvarchar( -) not NULL, Genderint not NULL) UseE_market--Add columnar alter+table+ table name +add+ new column name + data typeAlter TableUserInfoAddEmailvarchar( -)Alter TableUserInfoAddUserAddressnvarchar( $)Alter TableUserInfoAddPhonevarchar( -) not NULLCreate TableOrderInfo (OrderIDint Identity(1,1)Primary Key not NULL,--Order NumberUseridvarchar( -) not NULL,--member accountCommodityidint not NULL,--Product numberAmountint not NULL,--QuantityPaymoneybigint not NULL,--Payment AmountPaywayvarchar( -) not NULL,--Payment MethodOrdertimedatetime not NULL,--Order Date Confirm int not NULL,--Are you sureSendgoodsint not NULL--whether shipping) UseE_marketCreate TableCommoditysort (--Identity column, auto grow, identity seed 1, auto grow 1SortIDint Identity(1,1) not NULL,--Category NumberSortnamevarchar( -) not NULL--Category name)
Sql-server Create a database, create a table