数据库

    科技2022-07-11  134

    一、增加(insert)

    1.常用

    insert into 表名 values(v1,v2.....);

    2.添加指定字段

    insert into 表名[(字段1 ...)] values(v1 ....);

    二、删除(delete)

    1.delete from 表名 where 条件;

    2.注意:.truncate 语句(慎用)该语句也是用来删除表,是无法恢复的

    truncate table 表名;

    三、修改(update)

    update t_name set 字段1 = 新值, 字段2 = 新值 ... where 条件 ;

    四、查找(select)

    查询的结果也为一张虚拟的表 1.查看表中所有的内容

    select * from 表名;

    2.查找表中指定的字段

    select 字段1,字段2.... from 表名;

    五、对表的简单修改(alter table)

    1.增加新的字段

    alter table 表名 add 字段名 字段类型 约束条件;

    2.修改字段类型

    alter table 表名称 modify 字段名 字段类型;

    3.修改字段名称

    alter table 表名称 change 旧字段名 新字段名 字段类型;

    4.修改表名称

    1.alter table 旧表名 rename 新表名; 2.rename table 旧表名 to 新表名;

    六、表的复制

    1.create table 新表名 like 源表; 2.create table 新表名 select * from 源表;

    Processed: 0.010, SQL: 8