複制表結構及表資料:
create table table_name_new as select * from table_name_old
複制表結構:
create table table_name_new like table_name_old
複制表資料:
insert into K20_JDBC_TMP select * from K20_JDBC;
設定為空字段資料為-1:
update K20_JDBC_TMP set JDBCTIME_MS=-1 WHERE JDBCTIME_MS is NULL;
清空表資料:
truncate table K20_JDBC_TMP
重命名表名:
ALTER TABLE old_name RENAME TO new_name
或者
rename table to table_new
添加字段的文法:
alter table tablename add (column datatype [default value][null/not null],….);
alter table K20_JDBC_TMP2 add T1 CHAR(20) default null; //預設允許為空
修改字段的文法:
alter table tablename modify (column datatype [default value][null/not null],….);
alter table K20_JDBC_TMP2 modify T1 CHAR(30) default null;
删除字段的文法:
alter table tablename drop (column);
alter table K20_JDBC_TMP2 drop column T1;
比較兩個表資料差異:
select * from B minus select * from A
selecet pno,cno from A minus select pno,cno from B
比較兩張表結構相同的表,并将不同的資料插入第三張表中。
insert into K20_JDBC_TMP2(TMZDIFF,WRITETIME,NODE,TIMESTAMP,IP,NODENAME,SERVERNAME,PROVIDERNAME,JDBCNAME,CREATECOUNT,CLOSECOUNT,POOLSIZE,FREEPOOLSIZE,USEDMAX_PCT,JDBCTIME,WAITTIME,USETIME,WAITINGTHREADCOUNT,JDBCTIME_MS,WAITTIME_MS,USETIME_MS) select * from K20_JDBC MINUS SELECT * FROM K20_JDBC_TMP