SQL增删改语句常用

创建table:
    create table  tab_name(
    col1  type;                                       约束:主键-外键-非空-检查-唯一
    col2  type;    
);                                                            删除表  : drop  table  tab_name ;

增加列:alter table tab_name  add   col5   type  default null ;
删除列:alter table tab_name drop  col5   ;

修改列属性:alter table tab_name  modify(col1   type );
修改列约束:alter table tab_name  add  primary key /unique(col1,col2,…);
          alter  table  tab_name  add foreign key (col1) references  tab_name(col1);
        alter table  tab_name  add  check ();

删除列约束:alter  table tab_name  drop constraint constra_name ;
插入内容:
insert into  tab_name(col1,col2,…)
    values(’ ’,’ ’ …);

修改现有行:
update tab_name
    set  col1=‘ X ’
        where col2= ‘Y’;

删除现有行:
delete from tab_name
    where col1=‘X’ ;

 

原文地址:https://www.cnblogs.com/askDing/p/5482077.html