oracle資料庫的一些操作

2021-09-29 01:53:50 字數 1858 閱讀 8678

oracle啟用禁用約束

alter table table_name disable|enable constraint constraint_name禁用或啟用約束

alter table table_name drop constraint constraint_name通過主鍵名刪除約束

-- 查詢獲得sql

select

'alter table '

||table_name||

' enable constraint '

||constraint_name||

';'from user_constraints where constraint_type=

'r';

select

'alter table '

||table_name||

' disable constraint '

||constraint_name||

';'from user_constraints where constraint_type=

'r';

ora-02292:違反完整約束條件(***.fk***)- 已找到子記錄的刪除方法

找到到子表的記錄

select a.constraint_name, a.table_name, b.constraint_name

from user_constraints a, user_constraints b

where a.constraint_type =

'r'and b.constraint_type =

'p'and a.r_constraint_name = b.constraint_name

and a.constraint_name =

'fk***'

--提示的報錯資訊fk...填入這裡。

刪除子表中的所有記錄

刪除主表的記錄

oracle欄位的操作

alter

table 表名 add

(欄位名 字段型別 預設值 是否為空)

;alter

table users add

(name varchar2(30)

default

'無'not

null

);

alter

table 表名 modify

(欄位名 字段型別 預設值 是否為空)

;alter

table users modify

(name varchar2(30)

default

'無'not

null

);

alter

table 表名 drop

column 欄位名;

alter

table users drop

column name;

alter

table 表名 rename

column 列名 to 新列名

alter

table users rename

column name to username

alter

table 表名 rename

to 新錶名

alter

table users rename

to new_users;

Oracle資料庫的一些操作

如何備份oracle資料庫 md f db bak date 0,10 exp userid bszlhr bszlhr orcl 14 file f db bak date 0,10 bszlhr date 0,10 dmp log f db bak date 0,10 log bszlhr da...

oracle 資料庫的一些sql操作

時間字段查詢的sql語句 select from mycontent t where t.create date to date 2010 06 21 yyyy mm dd 修改時間欄位的sql語句 update mycontent t set t.create date to date 2012....

一些資料庫的操作

建立乙個資料庫 create database database name 刪除乙個資料庫 drop database database name 顯示資料庫 show databases 進入某個資料庫 use database name 建立乙個資料表 create table database...