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*
Ïà¹ØÎĵµ£º
ÔÚÊý¾Ý¿â²éѯÊý¾Ýʱ£¬ÎÒÃǾ³£Ê¹ÓÃһЩº¯Êý£¬Ê¹ÎÒÃǵIJéѯ¸ü¼Ó·½±ã¿ì½Ý£¬ÏÂÃæ¾Í°ÑSQL ServerÖÐÎÒÃdz£Óõöº¯Êý¸øÁоٳöÀ´£¬¹©²Î¿¼¡£
1.×Ö·û´®º¯ÊýÓû§¿ØÖÆ·µ»Ø¸øÓû§µÄ×Ö·û´®£¬ÕâЩ¹¦ÄܽöÓÃÓÚ×Ö·ûÐÍÊý¾Ý¡£
2.ÈÕÆÚº¯ÊýÓÃÓÚ²Ù×÷ÈÕÆÚÖµ£¬ÎÒÃDz»ÄÜÖ±½Ó¶ÔÈÕÆÚÔËÓÃÊýѧº¯Êý¡£
3.Êýѧº¯ÊýÓÃÓÚ¶ÔÊýÖµ½øÐдúÊýÔËËã¡£
4.ϵͳº¯ ......
SQLÓÅ»¯µÄÔÔòÊÇ£º½«Ò»´Î²Ù×÷ÐèÒª¶ÁÈ¡µÄBLOCKÊý¼õµ½×îµÍ¡£
µ÷Õû²»Á¼SQLͨ³£¿ÉÒÔ´ÓÒÔϼ¸µãÇÐÈ룺
¼ì²é²»Á¼µÄSQL£¬¿¼ÂÇÆäд·¨ÊÇ·ñ»¹ÓпÉÓÅ»¯ÄÚÈÝ£»
¼ì²é×Ó²éѯ¿¼ÂÇSQL×Ó²éѯÊÇ·ñ¿ÉÒÔÓüòµ¥Á¬½ÓµÄ·½Ê½½øÐÐÖØÐÂÊéд£»
¼ì²éÓÅ»¯Ë÷ÒýµÄʹÓã»
¿¼ÂÇÊý¾Ý¿âµÄÓÅ»¯Æ÷;
²éѯµÄÒ»°ã¹æÔò
Ø ......
ʲôÊÇPL/SQL
PL/SQL(Procedural Language/SQL,¹ý³Ì»¯SQLÓïÑÔ£©ÊÇOracle¹«Ë¾ÔÚ±ê×¼SQLÓïÑԵĻù´¡ÉÏ·¢Õ¹µÄÓïÑÔ£¬Ëü½«±äÁ¿¡¢¿ØÖƽṹ¡¢¹ý³ÌºÍº¯ÊýµÈ½á¹¹»¯³ÌÐòÉè¼ÆµÄÒªËØÒýÈëSQLÓïÑÔ£¬´Ó¶øÄܹ»±àÖÆ±È½Ï¸´ÔÓµÄSQL³ÌÐò£»ÀûÓÃPL/SQLÓïÑÔ±àдµÄ³ÌÐò³ÆÎªPL/SQL³ÌÐò¿é£¬ÆäÖ÷ÒªÌØµãÈçÏ£º
¾ßÓÐÄ£¿é»¯µÄ½á¹¹
ʹÓùý³Ì»¯ÓïÑÔ¿ØÖƽ ......
µ±ÐÞ¸ÄÁ˵ǼÃÜÂëʱ£¬µ±Æô¶¯mssqlserverµÄʱºò»á³öÏÖerror 1069, means logon error. ÕâÊÇÓÉÓÚÒ»ÏÂ2¸öÔÒò1.sqlserverµÄÃÜÂëûÓÐͬ²½µÄÔÒò£¬ÐèÒªÔÚadministrator tools ->services-> right click mssqlserver -> property-> logon tab -> change passward to new one . 2.sqlserverµÄÆô¶¯Óû§²»¶Ô£¬ÐèÒªÔÚa ......
--¶¼Ð´ÁË ²Î¿¼Ï°É
ͨ³££¬ÄãÐèÒª»ñµÃµ±Ç°ÈÕÆÚºÍ¼ÆËãһЩÆäËûµÄÈÕÆÚ£¬ÀýÈ磬ÄãµÄ³ÌÐò¿ÉÄÜÐèÒªÅжÏÒ»¸öÔµĵÚÒ»Ìì»òÕß×îºóÒ»Ìì¡£ÄãÃǴ󲿷ÖÈË´ó¸Å¶¼ÖªµÀÔõÑù°ÑÈÕÆÚ½øÐзָÄê¡¢Ô¡¢Èյȣ©£¬È»ºó½ö½öÓ÷ָî³öÀ´µÄÄê¡¢Ô¡¢ÈյȷÅÔÚ¼¸¸öº¯ÊýÖмÆËã³ö×Ô¼ºËùÐèÒªµÄÈÕÆÚ£¡ÔÚÕâÆªÎÄÕÂÀÎÒ½«¸æËßÄãÈçºÎʹÓÃDATEADDºÍDATEDIFFº¯Êý ......