sql server中 创建数据表时说明怎么用代码写

2024-11-13 03:43:46
推荐回答(3个)
回答(1):

create table student

id int not NULL,
name varchar(10) not null


EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'学号' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'student', @level2type=N'COLUMN',@level2name=N'id'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'姓名' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'student', @level2type=N'COLUMN',@level2name=N'name'
GO

回答(2):

CREATE TABLE [dbo].[eFA_QA](
[QuestionID] [int] IDENTITY(1,1) NOT NULL,
[ApplicationID] [varchar](12) NOT NULL,
[Question] [nvarchar](500) NULL,
[Answer] [nvarchar](2000) NULL,
[Submitter] [varchar](10) NOT NULL,
[SubmitDate] [datetime] NOT NULL CONSTRAINT [DF_eacct_QA_SubmitDate] DEFAULT (getdate()),
[Answerer] [varchar](10) NULL,
[AnswerDate] [datetime] NULL,
[CCList] [nvarchar](500) NULL,
[IsActive] [tinyint] NOT NULL CONSTRAINT [DF_eFA_QA_IsActive] DEFAULT ((1)),
CONSTRAINT [PK_eFA_QA] PRIMARY KEY CLUSTERED
(
[QuestionID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 90) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'1:有效,0:无效' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'eFA_QA', @level2type=N'COLUMN',@level2name=N'IsActive'

--那段EXEC即是。从服务器名一直定义到字段名,及内容value

回答(3):

肯定是没保存吧/
你在重新建一张表试试`
用t-sql语句在查询分析器里建一张表
use
pubs
go
create
table
table1
(
u_id
int
primary
key
identity(1,1),
u_name
varchar(20)
)
然后再退了进去看看
pubs库里还有没有表