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ě頽廢

          主站蜘蛛池模板: 鹤山市| 金坛市| 科技| 林州市| 河北区| 修水县| 潮安县| 东源县| 清新县| 吴江市| 托克逊县| 剑川县| 永胜县| 翁源县| 古交市| 沙田区| 郑州市| 噶尔县| 滕州市| 晋州市| 三门县| 中卫市| 诸暨市| 来宾市| 巴彦县| 吉木乃县| 昌邑市| 惠水县| 类乌齐县| 武清区| 高雄县| 清苑县| 东丰县| 北宁市| 安达市| 西乌| 德令哈市| 雷山县| 桐乡市| 灵寿县| 邵阳县|