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 server中如何判断表或者数据库的存在,但在实际使用中,需判断Status状态位:
其中某些状态位可由用户使用 sp_dboption(read only、dbo use only、single user 等)进行设置:
1 = autoclose;使用 sp_dboption 设置。 数据库完全关闭,其资源在最后一个用户注销后释放。
4 = select into/bulkcopy;使用 sp_dbopti ......
SQL优化的原则是:将一次操作需要读取的BLOCK数减到最低。
调整不良SQL通常可以从以下几点切入:
检查不良的SQL,考虑其写法是否还有可优化内容;
检查子查询考虑SQL子查询是否可以用简单连接的方式进行重新书写;
检查优化索引的使用;
考虑数据库的优化器;
查询的一般规则
Ø ......
Select * from t_user_profile where convert ( varchar ( 21 ),regDate, 120 ) like ' 2008-05-07% ' 表名称:t_user_profile 日期字段名称:regDate
Select * from t_user_profile where convert(varchar(21),regDate,120) like '2008-05-07%'< ......
当修改了登录密码时,当启动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 ......
一个简单的小实例就明白~!
user表
在这张表中建立触发器
Create trigger tiggername
on user
for delete
as
begin ......