`
javaEE_dev
  • 浏览: 25100 次
  • 性别: Icon_minigender_1
  • 来自: 西安
最近访客 更多访客>>
文章分类
社区版块
存档分类
最新评论
阅读更多

大小写不敏感。

打印单引号时,需加多一个单引号作转义符。即连用两个单引号才可以打印一个。
    Begin dbms_output.put_line('I''m leaning');
    End;

注释:
单行注释:由两个连字符开始,到行尾。
   --Available
多行注释:由“/*”开头,“*/” 结尾。
如果在一行代码还没有写完前(指分号结束此语句之前),一定要使用多行注释格式。
SQL中的一行代码,不是按手写的格式定义的,而是按计算机解释格式(没有分号终止前,即使按了回车也都解释为一行)

      PL/SQL 块语法
[DECLARE]
        ---declaration statements
BEGIN
        ---executable statements
[EXCEPTION]
        ---exception statements
END


变量声明:Declare
    变量名  Type [Constant] [Not Null] [:=value];
“:=”是赋值,而“=”是比较语句。

数据类型:
        %Type       可以取出某字段的类型;如:s_emp.last_name%Type  --相当于Varchar2。
        %Rowtype    返回一整行的记录类型;如:s_emp%Rowtype       --这得注意各字段的顺序。

数字型:
Number:
Binary_Integer:

BoolLean类型:只有 True 和 False 两类。
        其中,Dull = False。

程序执行顺序的类型可分三种:
顺序
选择
        If ... Then ...
        Elsif  ... Then ...
        Else ...
        End If;
循环
一、LOOP循环:
  1.   Loop ... ;  Exit When boolean_expr ; End Loop;
  2.   Loop  If boolean_expr  Then  Exit;  End If;
            ...;  End Loop;

二、While循环:
       While  boolean_expression
          Loop  ...  End Loop;
        其中boolean_expression 值为False则立即退出循环。免另外写结束条件。
        可以使用Exit或Exit When 语句终止循环处理。

三、For循环:
       For loop_count IN [Reverse] low_bound..high_bound
             Loop   ...;   End Loop;
        免声明,默认loop_count为数值型。简化结束条件。
        IN Reverse 表示倒过来,由大值自减到小值
        例:        For cnt  IN  1..5  Loop  ...;   End Loop;        /*由1到5*/



常用PLSQL语句:
    DBMS_OUTPUT.PUT_LINE('v_Num_3 = ' || v_Num_3); --文件中要打印一些内容
    set serveroutput on; --使终端可打印出文件的结果; 使输出无效:set serveroutput off;

MySQL 常用语句:
终端登录: mysql -u username -p password  --进入本机的mysql;没设密码就留空
    执行脚本: mysql -u 用户名 -密码 </.../xxx.sql
执行脚本2:先登录,再 source /.../xxx.sql
    show variables like '%char%';  --查看数据库的字符集;utf8或gbk的则可支持中文
    show databases; --显示所有数据库目录
    use 数据库名; --进入某个数据库 (可以有很多个,我把这些数据库看作目录,这点不同于oracle)
    show tables; --显示此目录下各表格的名字
    desc 表名; --我们可以查看某个表中的数据类型结构
    create database 数据库名;  --建数据库目录
    drop database 数据库名;  --删除数据库整个目录
    create table 表名;  --建表(同oracle)
    drop table 表名; --连删表(删多个表用逗号隔开)



Note that all text commands must be first on line and end with ';'
?         (\?) Synonym for 'help'.
clear     (\c) Clear command.
connect   (\r) Reconnect to the server. Optional arguments are db and host.
delimiter (\d) Set statement delimiter. NOTE: Takes the rest of the line as new delimiter.
edit      (\e) Edit command with $EDITOR.
ego       (\G) Send command to mysql server, display result vertically.
exit      (\q) Exit mysql. Same as quit.
go        (\g) Send command to mysql server.
help      (\h) Display this help.
nopager   (\n) Disable pager, print to stdout.
notee     (\t) Donot write into outfile.
pager     (\P) Set PAGER [to_pager]. Print the query results via PAGER.
print     (\p) Print current command.
prompt    (\R) Change your mysql prompt.
quit      (\q) Quit mysql.
rehash    (\#) Rebuild completion hash.
source    (\.) Execute an SQL script file. Takes a file name as an argument.
status    (\s) Get status information from the server.
system    (\!) Execute a system shell command.
tee       (\T) Set outfile [to_outfile]. Append everything into given outfile.
use       (\u) Use another database. Takes database name as argument.
charset   (\C) Switch to another charset. Might be needed for processing binlog with multi-byte charsets.
warnings  (\W) Show warnings after every statement.
nowarning (\w) Donot show warnings after every statement.


分享到:
评论

相关推荐

    计算机软件编程学习笔记.rar

    03. PL SQL note.txt 04. CVS note.txt 05. Core Java exercise.txt 05. Core Java note.txt 06. OOAD & UML note.txt 07. Xml note.txt 08. JDBC note.txt 09. Hibernate note.txt 10_1. HTML&CSS note.txt 10_2. ...

    达内培训五个月以来的笔记:tarena_note

    03. PL SQL note.txt 04. CVS note.txt 05_1. Core Java exercise.txt 05_2. Core Java note.txt 06. OOAD & UML note.txt 07. Xml note.txt 08. JDBC note.txt 09. Hibernate note.txt 10_1. HTML note.txt 10_2. ...

    达内学习笔记全套

    SQL note》、《03. PL SQL note》、《04. CVS note》、《05. Core Java exercise》、《05. Core Java note》、《06. OOAD & UML note》、《07. Xml note》、《08. JDBC note》、《09. Hibernate note》、《10_1. ...

    PL SQL note

    PL SQL note

    PL/SQL Developer Plugins

    Note that for the 32 bit and 64 bit versions of PL/SQL Developer you will need to download the corresponding Plug-In version. A 32 bit Plug-In will be ignored by the 64 bit version of PL/SQL Developer...

    Nikto安全扫描工具

    Note: This is the short help output. Use -H for full help. 升级插件 root@91ri.org:/pentest/web/nikto# ./nikto.pl -update -h 指定扫描的目标 –p 端口 root@91ri.org:/pentest/web/nikto# ./nikto.pl -h ...

    plsql常见问题.docx

    存储过程在PL/SQL Developer中调试,提示 ORA-0131: Insufficient privileges.Note: Debugging requires the DEBUG CONNECT SESSION system privilege.

    plsqldev14.0.6.1988x64多语言版+sn.rar

    64位版本的 PLSQL 正式...PL/SQL Beautifier could add empty lines after “OPEN cursor” statement Opening the “Roles” folder in the Object Browser could display a popup message with the current username

    plsqldev14.0.6.1988x32多语言版+sn.rar

    32位版本的 PLSQL 正式...PL/SQL Beautifier could add empty lines after “OPEN cursor” statement Opening the “Roles” folder in the Object Browser could display a popup message with the current username

    利用 Oracle 和 PHP 管理分布式跟踪文件

    PL/SQL procedure completed successfully&quot; then everything is OK if you get something like this ... * ERROR at line 1: ORA-29532: Java call terminated by uncaught Java exception: java.security....

    12c – 使用跨平台增量备份来减少传输表空间的停机时间 (Doc ID 2102859.1).pdf

    (比如存储在 SYSTEM 表空间内的 pl/sql 对象,sequences 等),你可以使用数据泵来拷贝这些对象至目标系统。 注意: 考虑使用新release的版本V4的过程。 这个版本极大地简化了相关步骤。 请参考文档:V4 Reduce ...

    ora分析脚本

    - ash_sql &lt;sql_id&gt; Show all ash rows group by sampli_time and event for the specified sql_id - [-u ] degree degree of objects for a given user - [-u ] colstats stats for each table, column - [-u ]...

    rman_xttconvert_VER4.3.zip.7z

    (比如存储在 SYSTEM 表空间内的 pl/sql 对象,sequences 等),你可以使用数据泵来拷贝这些对象至目标系统。 注意: 考虑使用新release的版本V4的过程。 这个版本极大地简化了相关步骤。 请参考文档:V4 Reduce ...

Global site tag (gtag.js) - Google Analytics