PL/SQL ѧϰ±Ê¼Ç2
±äÁ¿ÉùÃ÷
Syntax:
identifier [CONSTANT] datatype [NOT NULL] [:= | DEFAULT expr];
SQL> declare
2 a date;
3 b number(20) not null :=100;
4 c varchar2(10);
5 d constant number(20) default 1000;
6 begin
7 null;
8 end;
9 /
PL/SQL procedure successfully completed.
SQL> var v_bind number
SQL> exec :v_bind := 2984;
PL/SQL procedure successfully completed.
SQL> r
1 declare
2 v_a number(20);
3 v_b constant number := 1000;
4 v_c constant number default 2000;
5 v_d varchar2(20) not null default 'asf';
6 begin
7 v_a := 2003;
8 dbms_output.put_line(v_a ||' '|| v_b ||' '|| v_c ||' ' || v_d || ' ' || '&a' || ' '||:v_bind) ;
9* end;
Enter value for a: 34567
old 8: dbms_output.put_line(v_a ||' '|| v_b ||' '|| v_c ||' ' || v_d || ' ' || '&a' || ' '||:v_bind) ;
new 8: dbms_output.put_line(v_a ||' '|| v_b ||' '|| v_c ||' ' || v_d || ' ' || '34567' || ' '||:v_bind) ;
2003 1000 2000 asf 34567 2984
PL/SQL procedure successfully completed.
Scalar ±êÁ¿ data type holds a single value and has no internal components.
number,
character,
date,
Boolean.
Character and number data types have subtypes that
associate a base type to a constraint. For example, INTEGERand POSITIVEare subtypes of the NUMBER
base type.
?CHAR [(maximum_length)]
? VARCHAR2(maximum_length)
? LONG
? LONG RAW
? NUMBER [(precision, scale)]
? BINARY_INTEGER
? PLS_INTEGER
? BOOLEAN
SQL> declare
2 v_job varchar2(20);
3 v_count binary_integer := 0;
4 v_total_sal number(9,2) := 0;
5 v_orderdate date := sysdate + 7;
6 c_tax_rate constant number(3,2) := 8.02;
7 v_valid boolean not null :=true;
8 begin
9 null;
10 end;
11 /
v_job: variable to store an employee job title
v_count: variable to count the iterations of a loop and initialized to 0
v_total_sal: variable to accumulate the total salary for a department and i
Ïà¹ØÎĵµ£º
ÔÚGoogleÉÏʹÓÓsql ·ÖÒ³”¹Ø¼ü×Ö½øÐÐËÑË÷£¬¼¸ºõËùÓеĴ𰸶¼ÊÇÄÇÈýÌõ¡£Æä¶þЧÂÊ×î¸ß£¬ÆäÈýʹÓÃÓα꣬ЧÂÊ×î²î¡£
ÏÂÃæÊÇÄÇÈýÖÖ·½·¨ £¨²åÈë´úÂëûÓÐsqlÑ¡Ï
·½·¨1£º
ÊÊÓÃÓÚ SQL Server 2000/2005
SELECT TOP Ò³´óС *
from table1
WHERE ......
1.Çå¿ÕÈÕÖ¾
DUMP TRANSACTION ¿âÃû WITH NO_LOG
2.½Ø¶ÏÊÂÎñÈÕÖ¾£º
BACKUP LOG Êý¾Ý¿âÃû WITH NO_LOG
......
ϱí˵Ã÷ÔÚ Microsoft SQL Server Êý¾Ý¿âÖж¨ÒåµÄ£¬»òÔÚ Transact-SQL
Óï¾äÖÐÒýÓõĸ÷ÖÖ¶ÔÏóµÄ×î´óÖµ£¨ÊýÁ¿»ò´óС£©¡£ÏÂ±í²»°üº¬ Microsoft® SQL Server 2000™ Windows® CE °æ¡£
×î´óÖµ£¨ÊýÁ¿»ò´óС£©
¶ÔÏó
SQL Server 7.0
SQL Server 2000
Åú´¦Àí´óС
65,536 * ÍøÂçÊý¾Ý°ü´óС1
65,536 * Í ......
create PROCEDURE [dbo].[P_PageTest]
@SQL Nvarchar(max), --SQLÓï¾ä²»°üÀ¨ÅÅÐò
@CurPage int, --µ±Ç°Ò³
@PageRows int, --Ò³Ãæ³ß´ç
@Order Nvarchar(20), --ÅÅÐò×Ö¶Î
@OrderType Nvarchar( ......
PL/SQL ²»¾ß±¸ÊäÈëÊä³öµÄÄÜÁ¦
µ«ÊÇ¿ÉÒÔÒÀ¿¿»·¾³À´Ö´ÐÐÊýÖµµÄÊäÈëÊä³ö¸øPL/SQL ¿é
SQLPLUS »·¾³ÓÃsubstitution variables ºÍ host(bind) variable À´´«ÈëÊýÖµ¸øPL/SQL¿é
substitution variable: such as a preceding ampersand &a
host(bind) variable : such as a preceding colon :x
Ìæ ......