惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园_首页
T
Threat Research - Cisco Blogs
GbyAI
GbyAI
Y
Y Combinator Blog
美团技术团队
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
博客园 - 【当耐特】
S
SegmentFault 最新的问题
IT之家
IT之家
Recent Announcements
Recent Announcements
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
阮一峰的网络日志
阮一峰的网络日志
T
The Blog of Author Tim Ferriss
Martin Fowler
Martin Fowler
Microsoft Azure Blog
Microsoft Azure Blog
V
Visual Studio Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
U
Unit 42
WordPress大学
WordPress大学
博客园 - Franky
L
LangChain Blog
人人都是产品经理
人人都是产品经理
小众软件
小众软件
博客园 - 叶小钗
罗磊的独立博客
酷 壳 – CoolShell
酷 壳 – CoolShell
大猫的无限游戏
大猫的无限游戏
云风的 BLOG
云风的 BLOG
Vercel News
Vercel News
雷峰网
雷峰网
腾讯CDC
Google DeepMind News
Google DeepMind News
博客园 - 三生石上(FineUI控件)
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Help Net Security
Help Net Security
C
Check Point Blog
Hacker News - Newest:
Hacker News - Newest: "LLM"
N
News and Events Feed by Topic
V2EX - 技术
V2EX - 技术
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Schneier on Security
Schneier on Security
博客园 - 聂微东
A
Arctic Wolf
H
Heimdal Security Blog
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Recent Commits to openclaw:main
Recent Commits to openclaw:main
T
The Exploit Database - CXSecurity.com
C
Cyber Attacks, Cyber Crime and Cyber Security
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Google DeepMind News
Google DeepMind News

博客园 - 周国选

SQL数据库中修改表的所有者 llinux mount 新建磁盘到指定目录 Centos下apache默认主页修改 CentOS Apache配置详解 Fotolog 的 Solaris/MySQL 架构 mysql不预读数据库信息(use dbname 更快,不会卡) Linux MySQL主从复制(Replication)配置 MySql常用命令总结 备份MySQL出现Can’t open file when using LOCK TABLES错误 Oracle的特色和选项 Oracle入门--启动和关闭详解 如何在sql*plus中使用方向键和删除键 SQL Plus常用命令 SELinux相关指令工具 在Linux上安装Memcached服务 LINUX常用命令 Linux VI/VIM常用命令 memcached telnet操作 Quartz.NET克隆表达式 - 周国选 - 博客园
ORACLE常用Script
周国选 · 2011-09-08 · via 博客园 - 周国选

2011-09-08 10:03  周国选  阅读(804)  评论()    收藏  举报

    1、查看当前所有对象
  
  SQL> select * from tab;
  
  2、建一个和a表结构一样的空表
  
  SQL> create table b as select * from a where 1=2;
  
  SQL> create table b(b1,b2,b3) as select a1,a2,a3 from a where 1=2;
  
  3、察看数据库的大小,和空间使用情况
  
  SQL> col tablespace format a20
  SQL> select b.file_id  文件ID,
  b.tablespace_name  表空间,
  b.file_name     物理文件名,
  b.bytes       总字节数,
  (b.bytes-sum(nvl(a.bytes,0)))   已使用,
  sum(nvl(a.bytes,0))        剩余,
  sum(nvl(a.bytes,0))/(b.bytes)*100 剩余百分比
  from dba_free_space a,dba_data_files b
  where a.file_id=b.file_id
  group by b.tablespace_name,b.file_name,b.file_id,b.bytes
  order by b.tablespace_name
  /
  dba_free_space --表空间剩余空间状况
  dba_data_files --数据文件空间占用情况
  
  
  4、查看现有回滚段及其状态
  
  SQL> col segment format a30
  SQL> SELECT SEGMENT_NAME,OWNER,TABLESPACE_NAME,SEGMENT_ID,FILE_ID,STATUS FROM DBA_ROLLBACK_SEGS;
  
  5、查看数据文件放置的路径
  
  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;
  
  6、显示当前连接用户
  
  SQL> show user
  
  7、把SQL*Plus当计算器
  
  SQL> select 100*20 from dual;
  
  8、连接字符串
  
  SQL> select 列1||列2 from 表1;
  SQL> select concat(列1,列2) from 表1;
  
  9、查询当前日期
  
  SQL> select to_char(sysdate,'yyyy-mm-dd,hh24:mi:ss') from dual;
  
  10、用户间复制数据
  
  SQL> copy from user1 to user2 create table2 using select * from table1;
  
  11、视图中不能使用order by,但可用group by代替来达到排序目的
  
  SQL> create view a as select b1,b2 from b group by b1,b2;
  
  12、通过授权的方式来创建用户
  
  SQL> grant connect,resource to test identified by test;
  
  SQL> conn test/test