sqlserver建表语句

版权声明: https://blog.csdn.net/eds124/article/details/82974328
USE [master]
GO
DROP DATABASE [mydata]
GO
CREATE DATABASE [mydata]
GO
USE [mydata]
GO
CREATE TABLE [dbo].[t_user]
(
    [id] [tinyint] IDENTITY(1,1) NOT NULL,
    [username] [nvarchar](max) NOT NULL DEFAULT (N'无'),
    [gender] [nvarchar](max) NOT NULL DEFAULT (N'无'),
    [birthday] [date] NOT NULL DEFAULT (N'1900-01-01'),
    [address] [nvarchar](max) NOT NULL DEFAULT (N'无'),
    [idnumber] [nvarchar](max) NOT NULL DEFAULT (N'无'),
    PRIMARY KEY ([id]),
    CHECK ([gender]=N'男' OR [gender]=N'女' OR [gender]=N'无')
)
insert into t_user ([username]) values (N'张三');
insert into t_user ([gender]) values (N'男');
insert into t_user ([birthday]) values (N'1980-1-1');
insert into t_user ([address]) values (N'北京市');
insert into t_user ([idnumber]) values (N'0');

declare @i int
set @i = 0
while @i < 240
begin
	insert into t_user ([username], [gender], [birthday], [address], [idnumber]) values (N'七七', N'女', N'1980-1-1', N'北京市东城区2号', N'110101198001010010');
	set @i = @i + 1
end
select * from t_user;
展开阅读全文

没有更多推荐了,返回首页