查找数据库中所有字段以对应的表
select from dba_tab_columns c where owner=''
查每个科目class 分数scro前三名
select id, name, class, scro
from (select row_number() over(partition by class order by scro desc) cnt,
id, name,
class,
scro from student) a
where <=3;
查找排序后的前三行
select *
from (select rw.*,rownum
from (select *
from student d
where = b'
order by desc) rw
where >=1
order by desc) n
where rownum <=3
表复制 insert into table_a (id,name,age) select from table_b;
-删除表数据的触发器
create or replace procedure delete_data
is begin
delete from test ;
commit;
exception
when no_data_found
then null;
when others
then raise;
end delete_data;
-定时删除每隔5分钟执行一次的计划
declare
x number;
begin
job =>x
what =>delete_data;'
next_date =>to_date('25/08/2008 00:00:00','dd/mm/yyyy hh24:mi:ss')
interval =>sysdate+1/24/12'
no_parse =>false
job number is: 'to_char(x));
commit;
end; -查看当前oracle计划
select job,next_date,next_sec,failures,broken from user_jobs;
-删除一个job
begin
dbms_为job号
end; -给新表插入旧表对应字段的所有数据
insert into aaa(id,name) select from bbb;
文章搜索: 【点击打包该文章】
到本站论坛,与同行交流】
select * from all_users查看所有用户
select name from v$database查看当前数据库
database test进入test数据库
select * from v$instance查看所有的数据库实例
shutdown immediate关闭数据库
alter user sys identified by new_password更改用户密码
select username,password from dba_users; ##查看当实例中的用户和密码
show parameter control_files查看控制文件;
select member from v$logfile查看日志文件
show parameter查看数据库参数
select * from user_role_privs查看当前用户的角色
select username,default_tablespace from user_users; ##查看当前用户的缺省表空间
alter user system identified by [password修改用户的密码
alter user "scott" account unlock解锁scott用户
show parameter processes查看最大会话数
查看当前库的所有数据表:
sql> select table_name from all_tables;
select * from all_tables;
sql> select
table_name from all_tables where table_name like ‘u’;
table_namedefault_auditing_options
查看表结构:desc all_tables;
创建用户并赋予权限创建用户并赋予权限create user mpss
identified by "mpss12"
default tablespace ts_mpss_data
temporary tablespace temp;
给用户赋予权限
grant connect to mpss;
grant resource,create session to mpss; 开发角色
grant create procedure to dbuser; #这些权限足够用于开发及生产环境给用户授权
grant dba to spms;--授予dba权限
grant unlimited tablespace to lxg;--授予不限制的表空间
grant select any table to lxg;--授予查询任何表
grant select any dictionary to lxg;--授予查询任何字典删除用户
drop user mpss cascade;
建表空间建表空间建立表空间create tablespace "ts_mpss_data"
logging
datafile '/mpss/data/ts_mpss_' size 1024m
extent management local segment space management auto建立临时表空间create
temporary tablespace "swvip" tempfile '/app/oracle/oradata/
sworacle/' size 5m extent management local uniform
size 1mcreate tablespace ts_mpss_data datafile '/mpss/data/ts_mpss_ 'size 1024m autoextend onautoextend on 自动扩展查看表空间查看表空间大小select "name",
to_char(((decode( null, 0, /1024 / 1024)) 1024 / 1024))*100,'99,990.9') used(%)
to_char((decode( null, 0, /1024 / 1024),'999,990.9') free (m)"
from d, a, f
where =
and (+sum_space(m)",blocks sum_blocks,space-nvl(free_space,0) "used_space(m)",
round((1-nvl(free_space,0)/space)*100,2) "used_rate(%)free_space "free_space(m)"
from select tablespace_name,round(sum(bytes)/(1024*1024),2) space,sum(blocks) blocks
from dba_data_files
group by tablespace_name) d,
select tablespace_name,round(sum(bytes)/(1024*1024),2) free_space
from dba_free_space
group by tablespace_name) f
where =
union all --if h**e tempfile
selecect "sum_space(m)",blocks sum_blocks,
used_space "used_space(m)",round(nvl(used_space,0)/space*100,2) "used_rate(%)
nvl(free_space,0) "free_space(m)"
from select tablespace_name,round(sum(bytes)/(1024*1024),2) space,sum(blocks) blocks
from dba_temp_files
group by tablespace_name) d,
select tablespace_name,round(sum(bytes_used)/(1024*1024),2) used_space,
round(sum(bytes_free)/(1024*1024),2) free_space
from v$temp_space_header
group by tablespace_name) f
where = 查看表空间物理文件的名称及大小表空间物理文件的名称及大小select tablespace_name, file_id, file_name,
round(bytes/(1024*1024),0) total_space
from dba_data_files
order by tablespace_name查看数据文件放置的路径sql> col file_name format a50
sql> select tablespace_name,file_id,bytes/1024/1024,file_name from dba_data_files order by file_id查看数据库库对象
select owner, object_type, status, count(*)count# from all_objects group by owner, object_type, status;
用系统管理员,查看当前数据库有几个用户连接:
sql> select username,sid,serial# from v$session;
扩表空间alter tablespace g000 add datafile '/dev/vgbilling/rg000_lv03' size 7500m;
给表g000增加一个7500m的逻辑卷'/dev/vgbilling/rg000_lv03检查被长时间锁的对象sql>select from v$locked_object a,dba_objects b where 文章出处:
sys用户登陆创建表空间:
sql> create tablespace lmsstemp datafile 'f:\oradata\lmss\' size 1
024m extent management local;
给表空间增加数据文件
alter tablespace lmsstemp add datafile 'f:\oradata\lmss\' size 1
024m;
更改表空间为自动扩展
sql> alter database datafile 'f:\oradata\lmss\' autoextend on;
查看表空间信息
sql> select file_name,tablespace_name,autoextensible from dba_data_files;
授权: create any table to leon
- create the user (用sys执行)
create user xx identified by xx123 default tablespace lmss temporary tablespace temp profile default;
- grant/revoke role privileges (用sys执行)
grant connect to xx;
-创建视图给hy用户(用leon用户)
create or replace view view_tablename as
select column。。。from table;
- grant/revoke object privileges
grant select, update on res_xim_card to hy;
-创建同义词
create synonym res_xim_card for ;
SQL高级
like 操作符用于在 where 子句中搜索列中的指定模式。原始的表 用在例子中的 persons 表 like 操作符实例。现在,我们希望从上面的 persons 表中选取居住在以 n 开始的城市里的人 我们可以使用下面的 select 语句 提示 可用于定义通配符 模式中缺少的字母 结果集 接...
SQL高级应用
数据库应用 sql高级 第一章 索引和视图。一。索引 语法 create index create unique 唯一性 索引名 on 表名 列名 聚集索引 每张表只能有一个。作用 存入数据时与索引的顺序相同。非聚集 可以有多个,最多能有249个。查看索引 语法 exec sp helpindex ...
sql注入 高级
看完入门篇和进阶篇后,稍加练习,破解一般的 是没问题了。但如果碰到表名列名猜不到,或程序作者过滤了一些特殊字符,怎么提高注入的成功率?怎么样提高猜解效率?请大家接着往下看高级篇。第一节 利用系统表注入sqlserver数据库。sqlserver是一个功能强大的数据库系统,与操作系统也有紧密的联系,这...