sqlplus简单使用

转至:https://www.cnblogs.com/inmeditation/p/11820688.html

sqlplus简单使用

 

登录

C:Usersinmeditation>sqlplus
请输入用户名:  scott
输入口令:

查看当前行长

SQL> show linesize;
linesize 80

查看当前页长

SQL> show pagesize;
pagesize 14

设置行长和页长

SQL> set linesize 100;
SQL> set pagesize 20;
SQL> show pagesize;
pagesize 20

查看当前所在用户

SQL> show user;
USER 为 "SCOTT"

更改当前用户的密码

SQL> alter user scott identified by scottpw;

用户已更改。

通过交互方式更改当前用户密码

SQL> passw
更改 SCOTT 的口令
旧口令:
新口令:
重新键入新口令:
口令已更改

切换到超级用户

SQL> conn sys as sysdba
输入口令:
已连接。
SQL> conn system/sys
已连接。

解锁scott用户

SQL> alter user scott account unlock;
用户已更改。

强制更改scott账户的密码

SQL> alter user scott identified by scottpw;
用户已更改。

退出当前数据库

SQL> disc
从 Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options 断开
SQL> show user;
USER 为 ""

退出数据库

SQL> exit
C:Usersinmeditation>
SQL> quit
从 Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options 断开

C:Usersinmeditation>

授权给scott用户 权限

SQL> grant connect,resource to scott;
授权成功。

SQL> grant select any dictionary to scott;
授权成功。

在scott中执行命令查询表结构

select a.OWNER 建表用户,
       a.TABLE_NAME 表名,
       a.COLUMN_NAME 列名,
       a.DATA_TYPE 数据类型,
       a.DATA_LENGTH 默认长度,
       a.DATA_PRECISION 最大长度,
       a.DATA_SCALE 小数位数,
       a.NULLABLE 可否为空,
       a.COLUMN_ID 列ID
from DBA_TAB_COLUMNS a
where a.TABLE_NAME = 'EMP'
order by a.COLUMN_ID asc;

原文地址:https://www.cnblogs.com/my-first-blog-lgz/p/13753808.html