用SQL语句断开某个数据库的所有活动连接
use master
go
if exists(select * from dbo.sysobjects where id = object_id(N'[dbo].[P_KillConnections]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[P_KillConnections]
GO
create proc P_KillConnections
@dbname varchar(200)
as
declare @sql nvarchar(500)
declare @spid nvarchar(20)
declare #tb cursor for
select spid=cast(spid as varchar(20)) from master..sysprocesses where dbid=db_id(@dbname)
open #tb
fetch next from #tb into @spid
while @@fetch_status=0
begin
exec('kill '+@spid)
fetch next from #tb into @spid
end
close #tb
deallocate #tb
go
--Usage
exec P_KillConnections 'DB'
相关文档:
想使用PL/SQL开发工具,但不想安装那个几百兆的oracle客户端,于是安装了oracle 10g inistant client,40多M吧。
安装后PL/SQL可以用了,但是查询出记录里面的中文却是乱码。折腾了好久才找出解决方法:
设置环境变量:NLS_LANG,值为Oracle数据库设置的字符集,在我的系统里面设置是:SIMPLIFIED CHINESE_CHINA.ZHS16GBK ......
create table Student(Sname varchar(10),Ssex varchar(5),Sage int,S# int)
insert into Student
select '夏亮','男','21','1004'
select '成平','男','20','1001' union all
select '王波','男','19','1002' union all
select '突然','女','19','1003'
create table Course(C# varchar(10),Cname v ......
SQL语句优化技术分析
操作符优化
IN 操作符
用IN写出来的SQL的优点是比较容易写及清晰易懂,这比较适合现代软件开发的风格。
但是用IN的SQL性能总是比较低的,从ORACLE执行的步骤来分析用IN的SQL与不用IN的SQL有以下区别:
ORACLE试图将其转换成多个表的连接,如果转换不成功则先执行IN里面的子查询, ......
DDL:数据库定义语言(create ,alter,modify)可自动提交。
DML:数据库操作语言(insert, update,alter)应设SET AUTOCOMMIT ON
DCL:数据库控制语言(grant,deny,revoke)
create table table_name (column_name type [not null] [constraint constraint_definition default XXXXXX] )
[primary key (column_name,col ......