当前位置 博文首页 > fenfyue的博客:2020-09-25

    fenfyue的博客:2020-09-25

    作者:[db:作者] 时间:2021-08-19 21:57

    2020/9/25数据库笔记

    (MySQL进入密码打不开???)

    表的创建

    提前准备

    • 表的名称
    • 字段的名称
    • 字段的数据类型? ?
    • 数值型:特点是能进行常规的+-*/运算,有数学意义?smallint(m) 2个字节? int(m)4个字节? ?bigint(m) 8个字节

    ? ? ? float(m,d)单精度浮点型,8为精度(4字节),m总个数,d小数位

    ? ? ? double(m,d)双精度浮点型,16位精度(8个字节),m总个数,d小数位

    ? ? ? varchar 变长型字符串(65535个字符)? ? ? enum枚举型? ?set 组合型

    • 日期型:datatime 日期和时间? ?timestamp,时间戳(会随着这条记录的修改而自动更新)
    • 二进制类型:

    列级完整性约束条件

    • 控制一个列的约束
    • 主键:不能为空,不能重复(只有一个)
    • 唯一:不能重复 (可有多个)

    ?

    desc student :查找查看表格?

    ?

    create table 表名?

    (s_no int (10)not null primary key,s_name char(20) not null,s_sex char(4) not null,s_class char(40) not nulll);

    ?

    create table? xscj;

    use xscj;

    create table SC?

    ?(s_no int(10)? not null primary key,Cno int(4) not null,Grade int (5) not null);

    decs SC:

    输入内容 :sname char(20) not null comment '姓名'

    ?

    alter table student (修改)

    (1)add 增加

    (2)modify 修改数据类型

    (3)change sage 修改一个字段

    cs
    下一篇:没有了