Sql-server Create a database, create a table

Source: Internet
Author: User

 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.