Oracle資料庫常用命令

來源:互聯網
上載者:User

標籤:constrain   lda   truncate   connect   授權   ase   where   視圖   datafile   

--查詢當前系統中的所有使用者  select * from all_users--查目前使用者下所有的表:  select * from tab where tname not like ‘%$%‘--查看目前使用者下所有的表(詳細資料)select * from user_tables--查資料庫中所有的表select * from all_tables--建立一個使用者(進行這項操作的目前使用者必須擁有DBA許可權)create user 使用者名稱 identified by 密碼--建立資料表空間create tablespace ts_mytestloggingdatafile ‘f:\oracle_xe_datafile\mytest.dbf‘size 32mautoextend on next 10m maxsize unlimited--刪除資料表空間drop tablespace hoteldata including contents and datafiles;/*使用者分三種類型  sys;//系統管理員,擁有最高許可權  system;//本地管理員,次高許可權  scott;//普通使用者,密碼預設為tiger,預設未解鎖    建立使用者未授權全部為普通使用者*/--刪除使用者(級聯)drop user testuser cascade--授予該使用者權限(進行這項操作的目前使用者必須擁有DBA許可權)grant connect, resource to 使用者名稱--connect角色是授予終端使用者的典型權利,最基本的  --修改會話    alter session  --建立會話    create session  --建立聚簇    create cluster  --建立資料庫連結    create database link  --建立序列    create sequence  --建立同義字    create synonym  --建立視圖    create view--resource角色是授予開發人員的  --建立聚簇    create cluster  --建立預存程序    create procedure  --建立序列    create sequence  --建表    create table  --建立觸發器    create trigger  --建立類型    create type --修改使用者口令格式 alter user 使用者名稱 identified by 密碼--鎖定 / 解鎖oracle使用者alter user 使用者名稱 account unlockalter user 使用者名稱 account lock--更改表的結構:alter table 表名 modify(name char(10))--查詢所有使用者預設資料表空間 select username, default_tablespace from dba_users--查看某一個使用者使用了哪些表和資料表空間select t.table_name, t.tablespace_name from dba_all_tables t where t.owner=‘COLLEGE‘--查詢目前使用者串連  select count(*) from v$session--查看目前使用者許可權  select * from session_privs; --添加主鍵alter table test add constraint pk_test primary key (userid);--刪除主鍵alter table 表名 drop constraint 主鍵名--查看當前資料庫所有使用者select * from dba_users--添加外鍵alter table 表2 add constraint 外鍵名 foreign key(表2中需要建外鍵的欄位) references 表1--刪除外鍵alter table test2 drop constraint fk_test2--查詢某個時間點的資料(可以用於恢複資料, 但是如果刪除表中資訊用的truncate, 就無法查詢了)select * from t_person as of timestamp to_date(‘2017-04-21 21:30:00‘,‘yyyy-mm-dd hh24:mi:ss‘);

 

Oracle資料庫常用命令

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.