研究生成SQL脚本
IF OBJECT_ID('DataAsInsCommand') IS NOT NULL DROP PROC DataAsInsCommand
GO
SET QUOTED_IDENTIFIER OFF
GO
CREATE PROC DataAsInsCommand (
@TableList varchar (200))
AS
SET NOCOUNT ON
DECLARE @position int, @exec_str varchar (2000), @TableName varchar (30)
DECLARE @name varchar(128), @xtype int, @status tinyint, @IsIdentity tinyint
SELECT @TableList = @TableList + ','
SELECT @IsIdentity = 0
SELECT @position = PATINDEX('%,%', @TableList)
WHILE (@position <> 0)
BEGIN
SELECT @TableName = SUBSTRING(@TableList, 1, @position - 1)
SELECT @TableList = STUFF(@TableList, 1, PATINDEX('%,%', @TableList), '')
SELECT @position = PATINDEX('%,%', @TableList)
 
相关文档:
(1) 选择最有效率的表名顺序(只在基于规则的优化
器中有效):
Oracle
的
解析器按照从右到左的顺序处理from子句中的表名,from子句中写在最后的表(基础表 driving
table)将被最先处理,在from子句中包含多个表的情况下,你必须选择记录条数最少的表作为基础表。假如有3个以上的表连接查询,
那就 ......
-- create by zh
-- n 是作物的时间,x 是希望在几点成熟,返回播种的时间
with t as
(
select 64 n,9 x from dual union all
select 64 n,13 x from dual union all
select 64 n,17 x from dual union all
select 64 n,20 x from dual
)
select '成熟时间:' || lpad(to_char(n),4,' ' ......
今天一个朋友问到这个问题,其实很好解决:
declare @dbname varchar(50)
declare c_database cursor for
select name from master.dbo.sysdatabas ......
创建外键约束
CREATE TABLE order_sample
(
orderid int PRIMARY KEY,
cust_id int FOREIGN KEY REFERENCES cuts_sample(cust_id) ON DELETE NO CASCADE
)
ON DELETE--用于控制尝试删除外键相关联的主表指向行时采取的操作
-NO ACTION
删除外键相关联的主表指向行时,报错
-CASCADE
删除外键相关联的主表指向行时 ......
SQL Lite
SQLite is a small C library that implements a self-contained, embeddable, zero-configuration SQL database engine.
It is a open source product and can be downloaded from http://www.sqlite.org/ . SQL Lite is best suited in Smart Client architecture, where we can locally store all ......