Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

SQL*Plus FAQ

 What is SQL*Plus and where does it come from?
SQL*Plus is a command line SQL and PL/SQL language interface and reporting tool that ships with the Oracle Database Client and Server software. It can be used interactively or driven from scripts. SQL*Plus is frequently used by DBAs and Developers to interact with the Oracle database.
If you are familiar with other databases, sqlplus is equivalent to:
"sql" in Ingres,
"isql" in Sybase and SQL Server,
"sqlcmd" in Microsoft SQL Server,
"db2" in IBM DB2,
"psql" in PostgreSQL, and
"mysql" in MySQL.
SQL*Plus's predecessor was called UFI (User Friendly Interface). UFI was included in the first Oracle releases up to Oracle 4. The UFI interface was extremely primitive and, in today's terms, anything but user friendly. If a statement was entered incorrectly, UFI issued an error and rolled back the entire transaction (ugggh).
 How does one use the SQL*Plus utility?
Start using SQL*Plus by executing the "sqlplus" command-line utility from the $ORACLE_HOME/bin directory. Some of the command line options:
userid/password@db -- Connection details
/nolog             -- Do not login to Oracle. You will need to do it yourself.
-s or -silent      -- start sqlplus in silent mode. Not recommended for beginners!
@myscript          -- Start executing script called "myscript.sql"
Look at this example session:
sqlplus /nolog
SQL> connect scott/tiger
SQL> select * from tab;
SQL> disconnect
SQL> exit
Please note that one must prepare the environment before starting sqlplus.
Linux/ Unix example:
$ . oraenv
ORACLE_SID = [orcl] ? orcl
$ sqlplus scott/tiger
Windows Example:
Click on "Start" -> "Run" and enter "cmd"
C:> set ORACLE_SID=orcl
C:> sqlplus scott/tiger
or...
C:> sqlplus scott/tiger@orcl
 What commands can be executed from SQL*


Ïà¹ØÎĵµ£º

SQLʱ¼äת»»¸ñʽ

select Convert( varchar(20) , ʱ¼ä×Ö¶Î , ¸ñʽ ) from ±í È磺select Convert(varchar(20),LOGIN_DATE,112) from dbo.C_PARTY_CLIENT 100£ºJun 22 2009 12:00AM 101£º06/22/2009 102£º2009.06.22 103£º22/06/2009 104£º22.06.2009 105£º22-06-2009 106£º22
select Convert(varchar(20),<ʱ¼ä×Ö¶Î>,<¸ñʽ>) f ......

sqlº¯Êý¡¡

1¡¢ISNULL ( check_expression , replacement_value )
²ÎÊý
check_expression
½«±»¼ì²éÊÇ·ñΪ NULLµÄ±í´ïʽ¡£check_expression ¿ÉÒÔÊÇÈκÎÀàÐ͵ġ£
replacement_valueÔÚ check_expressionΪNULLʱ½«·µ»ØµÄ±í´ïʽ¡£replacement_value ±ØÐëÓë check_expresssion ¾ßÓÐÏàͬµÄÀàÐÍ¡£
·µ»ØÀàÐÍ
·µ»ØÓë check_expression Ï ......

¾­µäSQLÓï¾ä´óÈ«

ÏÂÁÐÓï¾ä²¿·ÖÊÇMssqlÓï¾ä£¬²»¿ÉÒÔÔÚaccessÖÐʹÓá£
¡¡¡¡SQL·ÖÀࣺ
¡¡¡¡DDL—Êý¾Ý¶¨ÒåÓïÑÔ(CREATE£¬ALTER£¬DROP£¬DECLARE)
¡¡¡¡DML—Êý¾Ý²Ù×ÝÓïÑÔ(SELECT£¬DELETE£¬UPDATE£¬INSERT)
¡¡¡¡DCL—Êý¾Ý¿ØÖÆÓïÑÔ(GRANT£¬REVOKE£¬COMMIT£¬ROLLBACK)
¡¡¡¡Ê×ÏÈ,¼òÒª½éÉÜ»ù´¡Óï¾ä£º
¡¡¡¡1¡¢ËµÃ÷£º´´½¨Êý¾Ý¿â
......

PL/SQLѧϰ±Ê¼Ç¶þ


1.³£Á¿
¶¨ÒåÓï·¨¸ñʽ£º
³£Á¿Ãû constant ÀàÐͱêʶ·û [not null]:=Öµ;
È磺PI constant number(9):=3.1415;
2.»ù±¾Êý¾ÝÀàÐͱäÁ¿
»ù±¾Êý¾ÝÀàÐÍ
number  Êý×ÖÐÍ
int ÕûÊýÐÍ
pls_integer ÕûÊýÐÍ£¬²úÉúÒç³öʱ³öÏÖ´íÎó
binary_integer ÕûÊýÐÍ£¬±íʾ´ø·ûºÅµÄÕûÊý
char ¶¨³¤×Ö·ûÐÍ£¬×î´ó255¸ö×Ö·û
varchar2 ±ä³¤× ......

PL/SQLѧϰ±Ê¼ÇËÄ


ÊÂÎñÊÇOracle9iÖнøÐÐÊý¾Ý¿â²Ù×÷µÄ»ù±¾µ¥Î»£¬ÔÚPL/SQL³ÌÐòÖУ¬¿ÉÒÔʹÓÃ3¸öÊÂÎñ´¦Àí¿ØÖÆÃüÁî¡£
1. commitÃüÁî
commitÊÇÊÂÎñÌá½»ÃüÁî¡£Oracle9iÊý¾Ý¿âÖУ¬Îª±£Ö¤Êý¾ÝÒ»ÖÂÐÔ£¬ÔÚÄÚ´æÖÐΪÿ¸ö¿Í»§»ú½¨Á¢¹¤×÷Çø£¬¿Í»§»ú¶ÔÊý¾Ý¿â½øÐвÙ×÷µÄÊÂÎñ¶¼ÔÚ¹¤×÷ÇøÍê³É£¬Ö»ÓÐÖ´ÐÐcommitÃüÁîºó£¬¹¤×÷ÇøÄÚµÄÐÞ¸ÄÄÚÈݲÅдÈëµ½Êý¾Ý¿âÉÏ£¬³Æ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ