在sqlserver 下想复制一张表的,想到oracle下直接create table xxx as select * from ....即可。但是结果却是错误的,baidu一下发现。sqlserver的语法是 : select * into tablenew from tableold
CREATE TABLE #TemTable AS SELECT * FROM PlatformCoinExchangeRecord;
SELECT * INTO #TemTable FROM PlatformCoinExchangeRecord;
SELECT * FROM #TemTable;
DROP TABLE #TemTable;
CREATE TABLE #TemTable
(TotalOnlineDuration bigint,
ByPlayDuration int,
TotalPlayTimes int,
Task30 int,
Task60 int,
Task120 int);
INSERT INTO #TemTable exec NET_PW_GetPlayDurationTask 539;
SELECT * from #TemTable;
DROP TABLE #TemTable;
临时表可能创建后可能应为其他原因导致没有执行到drop,这样下次执行的时候临时表还存在,所以创建临时表以后最好会是做异常处理在catch中强制销毁。
CONTINUE HANDLE mysql可以用这个东西
CREATE TEMPORARY table IF NOT EXISTS alarmLeveltb
( devID bigint not null,
alarmLevel bigint not null
);
truncate TABLE alarmLeveltb;--清空表中的数据
如果不存在某个表就创建,mysql写法
IF objectproperty(object_id(@DbTableFileName),
'IsUserTable'
)
IS
NOT
NULL
PRINT
'EXISTS '
ELSE
PRINT
'NOT EXISTS '
貌似没有找到直接创建的办法,所以要约定好结果集