MySql基本语句

创建表:


CREATE TABLE article (
    id       bigint unsigned auto_increment comment '主键'  primary key,
    type   tinyint  default 1  null comment '类型 1|图片-2|附件',
    tags   varchar(20)  default '' not null comment '资源标记',
    is_delete  tinyint(1)  default 0  not null comment '是否删除 0未删除 1已删除',
    created_at datetime     default CURRENT_TIMESTAMP not null comment '创建时间',
    updated_at datetime    default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '更新时间'
)ENGINE=InnoDB DEFAULT CHARSET=utf8;

插入新数据


insert into article (type,date ) values (1,now());

insert into article(type,date ) values(1,now()),(5,now());

insert into article(type,date) select type,date  from article;

修改数据

update article set type=8 where id=1;

删除数据

delete from article where id=1;
讨论数量: 0

慎思笃行