sqlserver建表語句
阿新 • • 發佈:2018-12-14
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;