–新建表:
create table table1( id varchar(300) primary key, name varchar(200) not null);
–插入数据
insert into table1 (id,name) values (‘aa’,‘bb’);
–更新数据
update table1 set id = ‘bb’ where id=‘cc’;
–删除数据
delete from table1 where id =‘cc’;
–删除表
drop table table1;
–修改表名:
alter table table1 rename to table2;
–表数据复制:
insert into table1 (select * from table2);
–复制表结构:
create table table1 select * from table2 where 1>1;
–复制表结构和数据:
create table table1 select * from table2;
–复制指定字段:
create table table1 as select id, name from table2 where 1>1;
–条件查询:
select id,name (case gender when 0 then ‘男’ when 1 then ‘女’ end ) gender from table1