当前位置:首页 » 编程语言 » oraclesql查询表结构语句
扩展阅读
webinf下怎么引入js 2023-08-31 21:54:13
堡垒机怎么打开web 2023-08-31 21:54:11

oraclesql查询表结构语句

发布时间: 2022-09-10 15:21:38

1. oracle怎么通过sql查看表的结构

分两种方法:
1、在命令窗口通过如下语句:
desc表名;
2、用语句:
selectCOLUMN_NAME,DATA_TYPE,DATA_LENGTHfromuser_tab_colswheretable_name='TEST';

2. ORACLE环境下用SQL语句查询一个表的结构用什么语句

先看看如果你不加WHERE条件能不能取到数据,如果能,那就不是权限了。
另外,除了USER_TAB_COLUMNS,同样还有一张表,ALL_TAB_COLUMNS,是所有表空间的数据。也可以用这个表。

3. 查询oracle数据库所有表sql语句怎么写

查询系统表:select * from all_tables where table_name not in (select table_name from user_tables);
查询用户表:select * from user_tables;

4. oracle怎么通过sql查看表的结构

分两种方法:

1、在命令窗口通过如下语句:

desc表名;

5. 如何用SQL语句获取Oracle表结构

利用sql语句查询某个表的结构的方法:

通过Oracle中的user_tab_cols, user_col_comments, user_constraints, user_cons_columns表联合查询。
1、user_tab_cols用来获取对应用户表的列信息;
2、user_col_comments用来获取对应用户表列的注释信息;
3、user_constraints用来获取用户表的约束条件;
4、user_cons_columns约束中用户可访问列。

示例代码:
select t.table_name,
t.column_name,
t.data_type,
t.data_length,
t.nullable,
t.column_id,
c.comments,
(SELECT CASE
WHEN t.column_name = m.column_name THEN
1
ELSE
0
END
FROM DUAL) iskey
FROM user_tab_cols t,
user_col_comments c,
(select m.column_name
from user_constraints s, user_cons_columns m
where lower(m.table_name) = 'qh_outstoresabinfo'
and m.table_name = s.table_name
and m.constraint_name = s.constraint_name
and s.constraint_type = 'P') m
WHERE lower(t.table_name) = 'qh_outstoresabinfo'
and c.table_name = t.table_name
and c.column_name = t.column_name
and t.hidden_column = 'NO'
order by t.column_id

6. 如何用SQL语句获取Oracle表结构

方法:
通过Oracle中的user_tab_cols, user_col_comments, user_constraints, user_cons_columns表联合查询。
user_tab_cols用来获取对应用户表的列信息;
user_col_comments用来获取对应用户表列的注释信息;
user_constraints用来获取用户表的约束条件;
user_cons_columns约束中用户可访问列。

示例代码:
select t.table_name,
t.column_name,
t.data_type,
t.data_length,
t.nullable,
t.column_id,
c.comments,
(SELECT CASE
WHEN t.column_name = m.column_name THEN
1
ELSE
0
END
FROM DUAL) iskey
FROM user_tab_cols t,
user_col_comments c,
(select m.column_name
from user_constraints s, user_cons_columns m
where lower(m.table_name) = 'qh_outstoresabinfo'
and m.table_name = s.table_name
and m.constraint_name = s.constraint_name
and s.constraint_type = 'P') m
WHERE lower(t.table_name) = 'qh_outstoresabinfo'
and c.table_name = t.table_name
and c.column_name = t.column_name
and t.hidden_column = 'NO'
order by t.column_id

7. oracle统计查询 sql语句应该怎么写

select substrb(create_time,1,4) "年份",
sum(decode(substrb(create_time,6,2),'01',commission,0)) "1月",
sum(decode(substrb(create_time,6,2),'02',commission,0)) "2月",
sum(decode(substrb(create_time,6,2),'03',commission,0)) "3月",
sum(decode(substrb(create_time,6,2),'04',commission,0)) "4月",
sum(decode(substrb(create_time,6,2),'05',commission,0)) "5月",
sum(decode(substrb(create_time,6,2),'06',commission,0)) "6月",
sum(decode(substrb(create_time,6,2),'07',commission,0)) "7月",
sum(decode(substrb(create_time,6,2),'08',commission,0)) "8月",
sum(decode(substrb(create_time,6,2),'09',commission,0)) "9月",
sum(decode(substrb(create_time,6,2),'10',commission,0)) "10月",
sum(decode(substrb(create_time,6,2),'11',commission,0)) "11月",
sum(decode(substrb(create_time,6,2),'12',commission,0)) "12月"
from test
group by substrb(create_time,1,4)
此语句是按create_time字段是字符型给出的,如果你的表中此字段是日期型,则进行一下转化

8. oracle数据库如何查询表结构

在sql*plus中可以用DESC命令显示表结构,例如:DESC EMP

在PL/SQL中,通过左边的浏览器查看就可以了,例如下图:

9. oracle 查看表结构,表里的数据

1、首先,我们打开PLSQL工具连接到需要进行数据比对的ORACLE数据库。

10. Oracle的查询语句怎么写

1.create user username identified by password;//建用户名和密码oracle ,oracle
2.grant connect,resource,dba to username;//授权 grant connect,resource,dba,sysdba to username;
3.connect username/password//进入。
4.select table_name,column_name from user_tab_columns where table_name='TABLE_NAME';//查询表中的表名,字段名等等。 最后的table_name要大写。
5. 如何执行脚本SQL文件? SQL>@PATH/filename.sql;

7.查询用户下的所有表 select distinct table_name from user_tab_columns; ===仅显示一列表名。
8.如何搜索出前N条记录?
select * from tablename where rownum<n;--足矣。(--是注释用的标记)
9.查找用户下的所有表:select * from tab; --查询该用户下的所有表及视图(显示表名tname, 类型tabname和clusterid)
2、显示当前连接用户
SQL> show user –不能用在sql窗口 只能用在command命令窗口。
3、查看系统拥有哪些用户
SQL> select * from all_users;
4、新建用户并授权
SQL> create user a identified by a;(默认建在SYSTEM表空间下)
SQL> grant connect,resource to a;
5、连接到新用户
SQL> conn a/a –或者是connect a/a
6、查询当前用户下所有对象
SQL> select * from tab; --table或是view
7、建立第一个表
SQL> create table a(a number);
8、查询表结构
SQL> desc a
9、插入新记录
SQL> insert into a values(1);
10、查询记录
SQL> select * from a;
11、更改记录
SQL> update a set a=2;
12、删除记录
SQL> delete from a;
13、回滚
SQL> roll;
SQL> rollback;
14、提交
SQL> commit;
select * from
(select t.*,dense_rank() over (order by cardkind) rank from cardkind t)
where rank = 2;
46. 如何在字符串里加回车?
select 'Welcome to visit'||chr(10)||'www.CSDN.NET' from al ; --‘||chr(10)||’作为换行符

53. 如何使select语句使查询结果自动生成序号?
select rownum COL from table; --主要就是oracle中引入了rownum
54. 如何知道数据裤中某个表所在的tablespace?
select tablespace_name from user_tables where table_name='TEST'; --table_name名称要大写。
select * from user_tables中有个字段TABLESPACE_NAME,(oracle);
select * from dba_segments where …;
55. 怎么可以快速做一个和原表一样的备份表?
create table new_table as (select * from old_table);
59. 请问如何修改一张表的主键?
alter table aaa drop constraint aaa_key ;
alter table aaa add constraint aaa_key primary key(a1,b1) ;
60. 改变数据文件的大小?
用 ALTER DATABASE .... DATAFILE .... ;
手工改变数据文件的大小,对于原来的 数据文件有没有损害。
61. 怎样查看ORACLE中有哪些程序在运行之中?
查看v$session表
62. 怎么可以看到数据库有多少个tablespace?
select * from dba_tablespaces;