读书人

oracle 惯用sql2

发布时间: 2012-07-16 15:44:59 作者: rapoo

oracle 常用sql2
--修改表结构
alter table t_abc modify(act default 1);
alter table t_def add column1 type add column2 type add column3 type ... ;
alter table t_ggg drop column column_name;

alter table table_name rename column old_value to new_value;


3、修改字段

alter table table_name modify (column_name type);

--case
SELECT CASE SIGN(5 - 5)
WHEN 1 THEN
'Is Positive'
WHEN -1 THEN
'Is Negative'
ELSE
'Is Zero'
END
as accountTemp
FROM DUAL;

--查看数据内容存储结构
select t.type, dump(t.type),dump('汉') from t_abc t;
select chr(115) from dual;
select lengthb('袁') from dual;


--在command中执行,查看表结构
desc t_abc;

-- 查询空余表空间
select
tablespace_name,
count(*) as extends,
round(sum(bytes)/1024/1024, 2) as MB,
sum(blocks) as blocks
from dba_free_space group by tablespace_name;

--查询各个表空间容量
select tablespace_name, sum(bytes)/1024/1024 as MB from dba_data_files group by tablespace_name;

读书人网 >SQL Server

热点推荐