易截截图软件、单文件、免安装、纯绿色、仅160KB

PL/SQL例子

以下是经测验能正确运行的:
create    table t_emp_log212
(
who varchar2(10) not null,
action varchar2(10) not null,
actime date
);
create or replace trigger tri_emp_insert
before insert
on t_emp
begin
insert into t_emp_log(who,action,actime)values(user,'insert',sysdate);
end;
-------------------------------------------------------------------------------------------
set serveroutput on
declare
 v_empno emp.empno%type:=&empno;
 v_ename emp.ename%type;
 begin
select empno, ename into v_empno,v_ename from emp where empno=v_empno;
dbms_output.put_line(v_ename);
exception
 when others then
 dbms_output.put_line(' your empno is null,ename is null');
end;
-------------------------------------------------------------------------------------------
SET SERVEROUTPUT ON
declare
type tabletype1 is table of varchar2(10) index by binary_integer;
type tabletype2 is table of varchar2(10) index  by binary_integer;
table1 tabletype1;
table2 tabletype2;
begin
 table1(1):='大学';
 table1(2):='大专';
  table2(1):=88;
  table2(2):=55;
dbms_output.put_line(table1(1)||table2(1));
dbms_output.put_line(table1(2)||table2(2));
end;
-------------------------------------------------------------------------------------------
set serveroutput on;
declare
   v_grade char(10):=upper('&p_grade');/*upper将字符串全变大写 必须加引号 因为赋值以后显示为upper('A')而upper(A)A作为常量了*/
   v_result varchar2(20);
begin
 v_result:=
  case v_grade
  when 'A' then '90 分以上'
  when 'B' then '80分到90分之间'
  when 'C' then '60分到80分之间'
  else '不及格'
end;
dbms_output.put_line('grade'||v_grade||'result'||v_result);
end;
-------------------------------------------------------------------------------------------
set serverout on
declare
 v_item number(3):=1;
 begin
loop
  dbms_output.put_line(v_item);


相关文档:

SQL语句收集

一、基础
1、说明:创建数据库
CREATE DATABASE database-name
2、说明:删除数据库
drop database dbname
3、说明:备份sql server
--- 创建 备份数据的 device
USE master
EXEC sp_addumpdevice 'disk', 'testBack', 'c:\mssql7backup\MyNwind_1.dat'
--- 开始 备份
BACKUP DATABASE pubs TO testBack
4、说 ......

SQL Server:查看数据库用户权限(SQL 2005)

1. 查看 SQL 2005 用户所属数据库角色
use yourdb
go
select DbRole = g.name, MemberName = u.name, MemberSID = u.sid
from sys.database_principals u, sys.database_principals g, sys.database_role_members m
where g.principal_id = m.role_principal_id
and u.principal_id = m.member_principal_id
......

SQL SERVER 查看用户权限

--用户与角色关系
select a.uid as uid,a.status as uStatus,a.name as uName,
  b.uid as rId,b.status as rStatus,b.name as rName
from sysusers a inner join sysusers b on a.gid = b.uid
where a.issqlrole = 0 and a.isapprole = 0 and a.hasdbaccess = 1 and (b.issqlrole = 1 or b.isapprole = 1)
......

SQL Server 索引结构及其使用(二)

改善SQL语句
  很多人不知道SQL语句在SQL SERVER中是如何执行的,他们担心自己所写的SQL语句会被SQL SERVER误解。比如:
select * from table1 where name=''zhangsan'' and tID > 10000
和执行:
select * from table1 where tID > 10000 and name=''zhangsan''
  一些人不知道以上两条语句的执行效率是否一 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号