create or replace trigger t before update on test5 for each rowbegin insert into test55 values (:old.id,:old.name);end ; -------------------------------------------------------------------------------------- --表中插入数据时ID自动增长 create table ttt (id numbe
因自己学习测试需要,需要两个有大量不重复行的表,表中行数越多越好.手动编写SQL语句,通过循环,批量向表中插入数据,考虑到避免一致问题,设置奇偶行不同.个人水平有限,如有错误,还望指正. 语句如下: 1 --批量向表中插入大量数据语句(奇偶不同) 2 3 --判断测试表是否存在,存在则先删除再创建 4 if exists(select 1 from sysobjects where xtype='u' and name='table_test' ) 5 drop table table_test
declare @tablename varchar(200)declare @sql varchar(2000)declare cur_t cursor forselect name from sysobjects where xtype= 'U ' and status> =0 and name not in (select name from sysobjects where id in (select id from syscolumns where id in (select id f
--复制另一个数据库中的某张表的结构及数据--select * from Test.dbo.TestTable(查询表中所有数据) --into [表名] 插入当前数据库新表,如果没有该表就创建 select * into TestCopy from Test.dbo.TestTable --只复制表结构(1!=1等价于1<>1,只要where后的为false就可以)--把查询出的数据插入到新表,如果没有数据就只是复制表结构了select * into TestCopy from Test.d