MySQL相关的建表语句





create table class(
    cid int auto_increment primary key,
    caption VARCHAR(16)
)engine=innodb default charset=utf8;


create table student(
    sid int auto_increment primary key,
    sname char(12),
    gender char(1),
    class_id int,
    CONSTRAINT fk_s17_1 FOREIGN KEY (class_id ) REFERENCES class(cid)
)engine=innodb default charset=utf8;


create table teacher(
    tid int auto_increment primary key,
    tname VARCHAR(16)
)engine=innodb default charset=utf8;


create table course(
    cid int auto_increment primary key,
    cname char(12),
    teacher_id int,
    CONSTRAINT fk_s17_2 FOREIGN KEY (teacher_id ) REFERENCES teacher(tid)
)engine=innodb default charset=utf8;



create table score(
    sid int auto_increment primary key,
    student_id int,
    course_id int,
    number int,
    CONSTRAINT fk_s17_3 FOREIGN KEY (student_id ) REFERENCES student(sid),
    CONSTRAINT fk_s17_4 FOREIGN KEY (course_id ) REFERENCES course(cid)
)engine=innodb default charset=utf8;

我自己的建表语句:

主机表建表语句:depsys

create table host_table(
    host_id int auto_increment primary key,
    username char(12),
    password char(15),
    ip       char(30),
    port     int
)engine=innodb default charset=utf8;


create table depart_table(
    depart_id int auto_increment primary key,
    depart_name char(30)
)engine=innodb default charset=utf8;


create table user_table(
    user_id int auto_increment primary key,
    username char(12),
    password char(15),
    mailbox  char(30),
    depart_id int,
    constraint  c1 foreign key (depart_id) references depart_table(depart_id)
)engine=innodb default charset=utf8;



create table user_host_table(
    user_id int ,
    host_id int ,
    constraint  c2 primary key (user_id,host_id),
    constraint  c3 foreign key (user_id) references user_table(user_id),
    constraint  c4 foreign key (host_id) references host_table(host_id)
)engine=innodb default charset=utf8;

最近的建表语句:

建表语句:

create table dbs_info(
    id          bigint,
    type_no     varchar(20),
    handle_time varchar(30),
    yn          varchar(10),
    reason      varchar(30),
    tele        int default 0,
    constraint  c1 primary key (id)
)engine=innodb default charset=utf8;

INSERT INTO tbl_name (col1,col2) VALUES(col2*2,15); 

insert into dbs_info(id,type_no,handle_time,yn,reason) values(6844,'普通上线','2017年10月27日15:02:04','1','无drop语句');
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值