sql语句 如何创建一个表啊?

 我来答
刺任芹O
2022-11-16 · TA获得超过6.1万个赞
知道顶级答主
回答量:38.7万
采纳率:99%
帮助的人:8111万
展开全部

create table userinfo

(

id int primary key not null identity (1,1),

[name] char(20) unique,

age int check(age>10),

sex char(2)

)

建一个名叫userinfo的表,字段为

id ,自动+1,主键,不为空。

name ,char(20) 不重复。

age int类型,年龄必须大于10,否则会出现错误。

sex 性别 char(2)

扩展资料:

关于SQL语句(建库、建表、修改语句)

--- if exists(select * from sys.sysdatabases where name='ConstructionDB')begin use master drop database ConstructionDB end go create database ConstructionDB on()

if exists(select * from sysobjects where name ='ConstructionDB') --查找命令

drop DATABASE ConstructionDB --删除 命令

Create database ConstructionDB

on(

name='ConstructionDB_date',

filename='E:\技能抽查试题第二模块(数据库)\试题——1\任务一\ConstructionDB_date.mdf',

size=3mb,

maxsize=10mb,

filegrowth=5% --增长速度为

)

log on(

name='ConstructionDB_log',

filename='E:\技能抽查试题第二模块(数据库)\试题——1\任务一\ConstructionDB_date.ldf',

size=2mb,

maxsize=5mb,

filegrowth=1mb

)

使用T-SQL语句创建表

use ConstructionDB

go

查询 库中是否存在 此表 存在则删除

if exists(select * from sysobjects where name = 'T_flow_step_def') 

drop table T_flow_step_def

方法二:

IF OBJECT_ID (N'bas_CardType') IS NULL

BEGIN --如果不存在该表,则进行创建

--drop table com_CodeRecord

流程步骤定义表 

create table T_flow_step_def(

Step_no    int not null,     --流程步骤ID 

Step_name    varchar(30)    not null, --流程步骤名称 

Step_des    varchar(64)    not null,    --流程步骤描述

Limit_time    int not null,     --时限

URL     varchar(64)    not null,     --二级菜单链接 

备注    varchar(256)    not null, 

)

流程类别表

create table T_flow_type(

Flow_type_id char(3) not null, --流程类别号 

Flow_type_name    varchar(64)    not null, --流程类别名称 

In_method_id    char(3) not null, --招标方式代号 

In_choice_id    char(3) not null, --项目选项代号 

备注:varchar(256)    not null, 

)

标段情况表:

create table T_sub_project(

Project_id varchar(32)    not null, ---工程编号 

Sub_pro_id char(2) not null, -- 标段编号 

Flow_type_id char(3) not null, --流程类别号 

Sub_pro_name varchar(64)    not null,--标段名称(招标项目名称) 

Usb_no varchar(64)    not null, --密码锁号

In_method_id char(3) not null, --招标方式代号 

In_scope_id char(3) not null, --招标范围代号 

In_choice_id char(3) not null, --项目选项代号 

Proj_type_id char(3) not null, --项目性质代号 

Engi_type_id char(1) not null, --工程性质代号

Pack_type char(1) not null, ---发包方式 

Grade_type_idv char(1) not null,--评分类别号

Flag_done char(1) not null,--完成标志 

Flag_forcebreak char(1) not null,--强制中断标志 

备注    varchar(256)    not null,

)

已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式