MS SQL Server build Database Build Table

Source: Internet
Author: User


CREATE DATABASE Test

Use Test

--Create User Type table
CREATE TABLE usertype (
ID INT not NULL identity (primary key),
TypeName VARCHAR (+) DEFAULT NULL,

Typedescription VARCHAR (+) DEFAULT NULL,
)
exec sys.sp_addextendedproperty @name = ' ms_description ', @value = ' self-growing primary key ', @level0type = ' schema ', @level0name = ' dbo ', @ Level1type= ' table ', @level1name = ' usertype ', @LEVEL2TYPE = ' COLUMN ', @level2name = ' ID '
exec sys.sp_addextendedproperty @name = ' ms_description ', @value = ' user type name ', @level0type = ' schema ', @level0name = ' dbo ', @ Level1type= ' table ', @level1name = ' usertype ', @level2type = ' column ', @level2name = ' TypeName '
exec sys.sp_addextendedproperty @name = ' ms_description ', @value = ' user type description ', @level0type = ' schema ', @level0name = ' dbo ', @ Level1type= ' table ', @level1name = ' usertype ', @level2type = ' Coloum ', @level2name = ' typedescription '

--Create a user information data sheet

CREATE TABLE UserInfo (
ID INT not NULL identity (primary key),
UserName VARCHAR (+) DEFAULT NULL,
Userlogin VARCHAR (+) DEFAULT NULL,
UserPassword VARCHAR (+) DEFAULT NULL,
UserEmail VARCHAR (+) DEFAULT NULL,
usertype int DEFAULT NULL,
CONSTRAINT userinfo_ibfk_1 FOREIGN KEY (usertype) REFERENCES usertype (ID)
)
exec sys.sp_addextendedproperty @name = ' ms_description ', @value = ' self-growing primary key ', @level0type = ' schema ', @level0name = ' dbo ', @ Level1type= ' table ', @level1name = ' UserInfo ', @LEVEL2TYPE = ' COLUMN ', @level2name = ' ID '
exec sys.sp_addextendedproperty @name = ' ms_description ', @value = ' user name ', @level0type = ' schema ', @level0name = ' dbo ', @ Level1type= ' table ', @level1name = ' UserInfo ', @level2type = ' column ', @level2name = ' UserName '
exec sys.sp_addextendedproperty @name = ' ms_description ', @value = ' User login name ', @level0type = ' schema ', @level0name = ' dbo ', @ Level1type= ' table ', @level1name = ' UserInfo ', @level2type = ' Coloum ', @level2name = ' userlogin '
exec sys.sp_addextendedproperty @name = ' ms_description ', @value = ' password ', @level0type = ' schema ', @level0name = ' dbo ', @ Level1type= ' table ', @level1name = ' UserInfo ', @LEVEL2TYPE = ' COLUMN ', @level2name = ' UserPassword '
exec sys.sp_addextendedproperty @name = ' ms_description ', @value = ' e-mail ', @level0type = ' schema ', @level0name = ' dbo ', @ Level1type= ' table ', @level1name = ' UserInfo ', @level2type = ' column ', @level2name = ' useremail '
exec sys.sp_addextendedproperty @name = ' ms_description ', @value = ' user type ', @level0type = ' schema ', @level0name = ' dbo ', @ Level1type= ' table ', @level1name = ' UserInfo ', @level2type = ' Coloum ', @level2name = ' usertype '


MS SQL Server build Database Build Table

Related Article

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.