首 页 行业热点 新车 试驾评测 养车用车 车型库

oracle 语句都有什么

发布网友 发布时间:2022-04-21 07:58

我来回答

5个回答

懂视网 时间:2022-04-30 00:37

1

SELECT ‘alter table ‘|| t.table_name||‘ disable constraint ‘||t.constraint_name||‘;‘ 
FROM user_constraints t WHERE t.constraint_type = ‘R‘;

2

SELECT ‘ALTER TABLE ‘|| table_name || ‘ ENABLE CONSTRAINTS ‘ || t.constraint_name ||‘;‘
FROM user_constraints t
WHERE t.constraint_type = ‘R‘ ;

3

ALTER TABLE TBL_NAME DISABLE CONSTRAINTS FK_TBL_ID;

4

ALTER TABLE TBL_NAME ENABLE CONSTRAINTS FK_TBL_ID;

5

ALTER TABLE TBL_NAME ENABLE ALL TRIGGERS;

6

ALTER TABLE TBL_NAME DISABLE ALL TRIGGERS;

7

INSERT INTO tbl_import SELECT * FROM tbl_export;

8

GRANT SELECT ON tbl_export TO schema_out;

























几个有用的oracle语句

标签:

热心网友 时间:2022-04-29 21:45

查询语句-select * from table;
select * from table where 条件1=数值 and 条件2=数值;
select * from table where id in (select id from table);两表关联
select a.a,b.b,c.c from table1 a,table2 b,table3 c where a.id1=b.id2;
插入语句-insert into table (字段1,字段2,字段3,……)
values (数值1,数值2,数值3,……);
更新语句-update 表名 set 数值 where=id = 1;

添加列语句-alter table 表名
add (列名1 类型1,列名2 类型2,列名3 类型3,……);

查询随机20条记录-select * from( select * from emp order by dbms_random.value) where rownum <= 10;
修改列类型-alter table 表名
modify (列名1 类型1,列名2 类型2,列名3 类型3,……);
删除列语句-alter table 表名
drop column 列名s;
显示查询时间-set timing on;

删除表语句-deltet table 表名;

清空表数据-truncate table 表名;

修改列名 - ALTER TABLE emp RENAME COLUMN comm TO newa;

集合查询(无重复):select * from table_name union
select * from table_name;
集合查询(有重复):select * from table_name union all
select * from table_name;
差 集 查 询:select * from table_name minus
select * from table_name;

--------------------------------------------------------------------------------
运行脚本-start d:\文件名.sql;

编辑脚本-edit d:\文件名.sql;

另存为脚本-spool d:\文件.sql;
select * from emp;
spool off;

分页显示-set pagesize 页数;

行数显示-set linesize 行数;

创建用户-create user 用户名 identified by 密码;(需要SYS/SYSTEM权限才能建立用户)
赋予权限-grant resource to 用户名;(建表权限)
赋予查询权限-grant select on emp to 用户名;
赋予修改权限-grant update on emp to 用户名;
赋予所有访问权限-grant all on emp to 用户名;
--------------------------------------------------------
收回查询权限-revoke select on emp from 用户名;
传递权限-grant select on emp to 用户名2 with grant option;
账户锁定-
creata profile 名称 limit failed_login_attcmpts 输入次数* password_lock_time 锁定天数;
------------------------------DBA权限登录
alter user 想要锁定的用户名 profile 名称;
------------------------------DBA权限登录
解锁用户锁定-alter user 用户名 account unlock;
定期修改密码-create profile 名字 limit password_life_time 天数 password_grace_time 宽限天数;

切换用户-conn system/密码;
更改密码-password 用户名;
删除用户-drop user 用户名 cascade(删除用户及用户建立的所有表);

查询同样结构两表中的不同数据-select * from emp_tmp where empno not in(select empno from emp);

select * from v$session;
select * from v$version;

定义函数:
---------函数说明 函数是计算数字平方;
FUNCTION y2
(inx2 number)
return number is
Result number(2);
begin

Result := inx2*inx2;

return(Result);
end y2;

---------函数说明 函数是输入汉字然后输出拼音;
FUNCTION HZ
(inputStr in VARCHAR2)
RETURN VARCHAR2 iS
outputStr varchar2(10);
BEGIN
SELECT c_spell INTO outputStr FROM BASE$CHINESE WHERE C_WORD = inputStr;
RETURN outputStr;
END hz;
----------函数说明 函数是计算累加自然月;
FUNCTION month
(inmonth number,
inaddmonth number)
return varchar2 is
Result varchar2(6);
begin

Result :=substr(to_char(add_months(to_date(inmonth,'yyyymm'),inaddmonth),'yyyymmdd'),1,6);

return(Result);
end month;

select to_char(add_months(trunc(sysdate),-1),'yyyymmdd') from al;--取上个月的日期;
select to_char((sysdate-30),'yyyymmdd') from al; ---去当前日期前30天日期;

ORACLE 随机数
DBMS_RANDOM.VALUE(low IN NUMBER,high IN NUMBER) RETURN NUMBER;
select round(dbms_random.value(x,x)) from al;

ORACLE 取当前时间并按毫秒计算
select systimestamp from al;

select * from cda_datasource---中继表

热心网友 时间:2022-04-29 23:03

select t.*,rowid from T_NAME t 这种语句吗?
用种样式的语句查询数据后,可以在PLSQL DEV中的结果集中直接编辑数据。点一下GRID上面的“锁”样子的按钮就可以编辑数据了!

热心网友 时间:2022-04-30 00:38

update+set+where
delect+from+where
insert+into+values(....)

热心网友 时间:2022-04-30 02:29

select * from table
update table where
delete frome table

声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com