Oracle常用命令

          Posted on 2007-09-19 13:18 優雅Dě頽廢 閱讀(307) 評論(0)  編輯  收藏 所屬分類: Oracle

          用戶登陸

          Connect

          查看當前用戶

          Show user;

          查看所有用戶

          Select username from dba_users;

          創建用戶

          Create user 'Name' identified by 'Password';

          授BDA最高權限

          Grant DBA to 'Name';

          授所有普通權限

          Grant connect,reource to 'Name';

          授權登陸

          Grant create session to 'Name';

          授權建表

          Grant create table BMW();

          授權無限表空間

          Grant create umlimited tablespace to 'Name';

          授查詢權限

          Grant select on BMW to 'Name';

          撤消查詢權限

          Revoke select on BMW to 'Name';

          修改自己的密碼(登陸自己的用戶)

          Alter user 'name' identified by 'password';

          修改別人的密碼(登陸超級用戶)

          Alter user 'name' identified by 'password';

          不輸入密碼登陸(*只能登陸SYS用戶)

          Connect / as sysdba

          數據庫操作部分

          建表

          create table BMW(

          2 SN number(10) constraint zph1 primary key,

          3 Model varchar2(20) constraint zph2 not null,

          4 Color varchar2(10) constraint zph3 references BMW(Color),

          5 Barcode number(30) constraint zph4 unique,

          6 Price number(7) constraint zph5 check(Price between 10 and 90));

          添加字段

          Alter table 'Apellation' add('fieldname' 'fieldtype');

          刪除字段

          Alter table 'Apellation' drop column 'fieldname';

          修改字段長度

          Alter table 'Apellation' modify('fieldname' 'fieldtype');

          修改字段類型

          Alter table 'Apellation' modify('fieldname' 'fieldtype');

          向表中插入一條記錄(所有字段)

          Insert into 'Apellation' values('data','data',data,);

          向表中插入一條記錄(部分字段)

          Insert into 'Apellation'('fieldname') values('data');

          修改表中一個字段

          Updata 'Apellation' set 'fieldname'='xxx' where 'fieldname'='id';

          刪除表中所有記錄

          Delete from 'Apellation';

          刪除表的結構和記錄

          Drop table 'Apellation';

          查看某個表所有記錄

          Select * from 'Apellation';

          查看某個表指定記錄

          Select 'fieldname','fieldname' from 'Apellation';

          查看別人的表的記錄(在別人先授查表權情況下)

          Select * from 'name'.'Apellation';

          查看當前用戶下所有表

          Select * from tab;

          查看表結構

          desc 'Apellation';

          控制不換行顯示

          Set linesize 'Parameter'

          控制每頁顯示行數

          Set pagesize 'Parameter'

          升序排列顯示

          Select * from 'Apellation';

          交互式插入記錄

          Insert into 'Apellation' values('&data','&data',&data,);

          轉義字符

          set escape on

          Insert into 'Apellation' values('data','data',da\&ta,);

          特殊命令部分

          清除屏幕

          Clear screen

          文件日志命令

          Spool F:\zph.txt

          Spool off

          提交命令

          Commit

          回滾命令

          Rollback

          設置保存點

          Savepoint 'zph1'

          查當前日期格式

          select * from nls_session_parameters;

          更改日期格式

          Alter session set nls_date_format='yyyy-mm-dd';

          更改數字顯示格式

          Column barcode format 999999999999999999999999999999;

          調整行寬

          Set linesize 200

          調整顯示字數

          Set pagesize 100

          posts - 13, comments - 1, trackbacks - 0, articles - 0

          Copyright © 優雅Dě頽廢

          主站蜘蛛池模板: 五常市| 万山特区| 徐水县| 曲麻莱县| 满城县| 永丰县| 丰都县| 加查县| 兴义市| 泾川县| 轮台县| 安乡县| 仪陇县| 泸溪县| 蛟河市| 元阳县| 夹江县| 东乌珠穆沁旗| 鄂温| 甘孜县| 宝山区| 海淀区| 河池市| 林甸县| 麻城市| 神池县| 崇文区| 洛扎县| 宁化县| 景洪市| 昔阳县| 永新县| 长垣县| 百色市| 大英县| 普定县| 兰溪市| 屏边| 罗平县| 英德市| 南平市|