MYSQL-具体代码-创建表

/*创建顾客表*/

create table if not exists customer(

    c_id char(6) primary key,

//为主键,若是需要多个的话,则需要写成primary key(字段一,字段二)

    name varchar(30)not null,

//指定了NOT NULL,若插入空值,则会插入失败;而NULL为默认状态,可不写

    location varchar(30),

    salary decimal(8,2)

);

/*创建银行表*/

create table if not exists bank(

    b_id char(5) primary key,

    bank_name char(30) not null

);

/*创建存款表(注意外键的代码使用)*/

create table if not exists deposite(

    d_id int(10) auto_increment primary key,

    c_id char(6),

    b_id char(5),

    dep_date date,

    amount decimal(8,2),

    constraint FK_c_id foreign key(c_id) references customer(c_id)

);

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容