利用pl/sql执行本地的sql文件中的sql语句
功能:pl/sql执行本地的sql文件中的sql语句
说明:比如:e:\zhaozhenlong下有create_table.sql文件,则按如下方法执行:
步骤:
1、在pl/sql的command window下,
或在windows的开始/'运行'下,sqlplus /nolog; connect cs@orademo;
2、执行:
@@e:\zhaozhenlong\drop_table.sql
@@e:\zhaozhenlong\create_table.sql
/*
说明:.sql文件名字中不能有空格,
如create_table.sql是合法的,create table.sql是非法的。
文件内容:
drop_table.sql文件内容:
drop table tb_zhaozhenlong6;
drop table tb_zhaozhenlong5;
create_table.sql文件内容:
--drop table tb_zhaozhenlong5;
create table tb_zhaozhenlong5(
c1 varchar2(10) not null constraint pk_zhaozhenlong5 primary key,
c2 varchar2(10) not null ,
c3 varchar2(10) not null constraint un_zhaozhenlong5 unique,
c4 char(1) not null constraint ck_zhaozhenlongddd check(c4 in('0','1')) ,
c5 char(1) not null,
constraint un_zhaozhenlong51 unique(c1,c2),
constraint ch_zhaozhenlong51 check(c5 in('Y','N'))
);
--drop table tb_zhaozhenlong6;
create table tb_zhaozhenlong6(
c1 varchar2(10) not null, constraint fk_zhaozhenlong6 foreign key(c1) references tb_zhaozhenlong5(c1),
c2 varchar2(10) not null,
&nb
相关文档:
这里介绍sql server2005里面的一个使用实例:
CREATE TABLE tb(province nvarchar(10),city nvarchar(10),score int)
INSERT tb SELECT '陕西','西安',3
UNION ALL SELECT '陕西','安康',4
UNION ALL SELECT '陕西','汉中',2
UNION ALL SELECT '广东','广州',5
UNION ALL SELECT '广东','珠海',2
UNION ......
我们在做很多项目时都要涉及到数据库,特别是一些比较大型的web项目,更是有较大的并发处理,所以对数据库的操作有可能会产生死锁,对于数据库的死锁,一般数据库系统都会有一套机制去解锁,一般不会造成数据库的瘫痪,但解锁的过程会造成数据库性能的急速下降,反映到程序上就会造成程序的反应性能的下降,并 ......
SQL Server 几个好用的SQL语句
1、复制表
select * into desttable from srctable
将 srctable 完整地复制一份到 desttable 中,当然后面也可以加上条件来限定需要复制的记录
要求:desttable 必须为不存在的表名。
insert into desttable(column1, column2) select columna, columnb from sr ......
此部分内容创建一个轻量级T-SQL测试套件,总共有3个脚本:
用于创建测试平台数据和待测存储过程的脚本
--======================
--makeDbTestAndResults.sql
use master
go
if exists (select * from sysdatabases where name = 'DbTestAndResults')
drop database makeDbTes ......
In:等值连接,用来查找多表相同字段的记录
Not In:非等值连接,用来查找不存在的记录
Inner join:内连接,主要用来查找都符合条件的记录
Left join:左连接,主要用来查找左边有,右边没有的用空值表达
Right join:右连接,主要用来查找右边有,左边没有的用空值表达
Order By:升序 Asc 降序 Desc
Group By:分组排序 ......