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