oracle字段名怎么取 oracle 字段名称长度

oracle 正则表达式或其它方法求字段名SELECT LISTAGG(REGEXP_SUBSTR('decode(PERIOD_DURATION,0,0,IN_TOT_CELLS_VP*53/1000/(PERIOD_DURATION*60))',
'[A-Z_] ', 1, LEVEL), ',') WITHIN GROUP(ORDER BY LEVEL)
FROMDUAL
CONNECT BY LEVEL = REGEXP_COUNT('decode(PERIOD_DURATION,0,0,IN_TOT_CELLS_VP*53/1000/(PERIOD_DURATION*60))',
'[A-Z_] ')
必须11g以上版本,匹配 大写的字母和_组成的字段,如果decode是大写的话,先把decode replace掉
oracle 使用sql获取数据库表、表的字段的多种方法--第一种方法:
查询dba_tab_columns
复制代码
代码如下:
select
COLUMN_NAME,DATA_TYPE,DATA_LENGTH
from
dba_tab_columns
where
table_name
=upper('表名')
order
by
COLUMN_NAME
--这种方法需要有DBA权限
--第二种方法:
查询user_tab_cols
select
COLUMN_NAME,DATA_TYPE,DATA_LENGTH
from
user_tab_cols
where
table_name=upper('表名')
order
by
COLUMN_NAME
--这种方法只能查找当前用户下的表
--第三种方法:
查询ALL_TAB_COLUMNS
select
distinct
COLUMN_NAME,DATA_TYPE,DATA_LENGTH
from
ALL_TAB_COLUMNS
WHERE
TABLE_NAME=
upper('表名')
--这种方法可以查询所有用户下的表
---------------------------补充-------------------------------------------------------------
复制代码
代码如下:
--增加字段
alter
table
cw_srcbpb
add
(SRCBPB_RJBPBL
varchar2(100)
);
alter
table
cw_srcbpb
modify
(SRCBPB_RJBPBL
number(30,3)
);
--Oracle查看所有表和字段
--获取表:
select
table_name
from
user_tables;
--当前用户的表
select
table_name
from
all_tables;
--所有用户的表
select
table_name
from
dba_tables;
--包括系统表
select
table_name
from
dba_tables
where
owner='LBSP';
--获取用户***所拥有的表这里的用户名要记得是用大写的 。
--
获取表字段:其实这里是根据用户的权限来获取字段的属性(表名要大写)
select
*
from
user_tab_columns
where
Table_Name='用户表';--获取用户表的所有字段还有字段的属性 。
select
*
from
all_tab_columns
where
Table_Name='用户表';--获取用户表的所有字段还有字段的属性 。所属用户是***
select
*
from
dba_tab_columns
where
Table_Name='用户表';--获取用户表的所有字段还有字段的属性 。所属用户是***
--获取表注释:
select
*
from
user_tab_comments
--user_tab_comments:table_name,table_type,comments
--相应的还有dba_tab_comments,all_tab_comments,这两个比user_tab_comments多了ower列 。
--获取字段注释:
select
*
from
user_col_comments
--user_col_comments:table_name,column_name,comments
--相应的还有dba_col_comments , all_col_comments,这两个比user_col_comments多了ower列 。
--查询出用户所有表的索引
select
*
from
user_indexes
--查询用户表的索引(非聚集索引):
select
*
from
user_indexes
where
uniqueness='NONUNIQUE'
--查询用户表的主键(聚集索引):
select
*
from
user_indexes
where
uniqueness='UNIQUE'
--查询表的索引
select
t.*,i.index_type
from
user_ind_columns
t,user_indexes
i
where
t.index_name
=
i.index_name
and
t.table_name='NODE'
--查询表的主键
select
cu.*
from
user_cons_columns
cu,
user_constraints
au
where
cu.constraint_name
=
au.constraint_name
and
au.constraint_type
=
'P'
AND
cu.table_name
=
'NODE'
--查找表的唯一性约束(包括名称,构成列):
select
column_name
from
user_cons_columns
cu,
user_constraints
au
【oracle字段名怎么取 oracle 字段名称长度】where
cu.constraint_name=au.constraint_name
and
cu.table_name='NODE'
--查找表的外键
select
*
from
user_constraints
c
where
c.constraint_type
=
'R'
and
c.table_name='STAFFPOSITION'
--查询外键约束的列名:
select
*
from
user_cons_columns
cl
where
cl.constraint_name
=
外键名称
--查询引用表的键的列名:
select
*
from
user_cons_columns
cl
where
cl.constraint_name
=
外键引用表的键名
Oracle用sql语句怎样获取表下所有主键字段名?1、查表oracle字段名怎么取的时候需要用到user_tables、all_tablesoracle字段名怎么?。瑄ser_tables查出来oracle字段名怎么取的是该用户拥有的表oracle字段名怎么取 , all_tables查出来的是所有用户的表 。
2、用sql查表的字段
查表的字段需要用到user_tab_columns、all_tab_columns , 一样的前者只能查到该用户拥有的表,后者可以查询所有用户的表 。
oracle中怎么更改表中字段名 首先方法是使用RENAME关键字:
修改字段名:alter table 表名 rename column 现列名 to 新列名;
修改表名:alter table 表名 rename to 新表名
增加字段语法:alter table tablename add (column datatype [default value][null/not null],….);
说明:alter table 表名 add (字段名 字段类型 默认值 是否为空);
例:alter table sf_users add (HeadPIC blob);
例:alter table sf_users add (userName varchar2(30) default '空' not null);
修改字段的语法:alter table tablename modify (column datatype [default value][null/not null],….);
说明:alter table 表名 modify (字段名 字段类型 默认值 是否为空);
例:alter table sf_InvoiceApply modify (BILLCODE number(4));
删除字段的语法:alter table tablename drop (column);
说明:alter table 表名 drop column 字段名;
例:alter table sf_users drop column HeadPIC;
字段的重命名:
说明:alter table 表名 renamecolumn列名 to 新列名(其中:column是关键字)
例:alter table sf_InvoiceApply rename column PIC to NEWPIC;
表的重命名:
说明:alter table 表名 rename to新表名
例:alter table sf_InvoiceApply rename tosf_New_InvoiceApply;
jsp获取oracle表的字段名用这个查询语句试试
select * user_tab_columns c where c.TABLE_NAME='SCORE'
c#获取oracle数据库表字段名我的做法是oracle字段名怎么?。?
a.sql是静态的,一个语句无法实现多种功能 。需要一个动态变化的语句 。
b.pl/sql可以生成动态语句,但是无法直接select 出结果 。
如:
create or replace procedure selectx
(v_field_nam in varchar2
)
is
begin
execute immediate 'select '|| v_field_nam ||' from dual ';
end selectx;
/
c.利用'' 的值替换功能,也可以实现oracle字段名怎么取你要的效果,
例如:
--1.建立测试表:
create table t_mytable
(
c1number
,c2number
);
--2插入样本数据:
insert into t_mytable
select 1 , 2 from dual;
commit;
insert into t_mytable
select 3 , 4 from dual;
commit;
pzw select * from t_mytable;
12
34
--带输入参数的sql语句:
pzw select cnum from t_mytable;
Enter value for num: 1
old1: select cnum from t_mytable
new1: select c1 from t_mytable
1
3
2 rows selected.
pzw select cnum from t_mytable;
Enter value for num: 2
old1: select cnum from t_mytable
new1: select c2 from t_mytable
2
4
2 rows selected.
如果对您有帮助,请记得采纳为满意答案,谢谢!祝您生活愉快!
vaela
oracle字段名怎么取的介绍就聊到这里吧 , 感谢你花时间阅读本站内容,更多关于oracle 字段名称长度、oracle字段名怎么取的信息别忘了在本站进行查找喔 。

    推荐阅读