SQL基础操作_3_数据字典(涵盖SQL ServerOracleMysql常见系统数据字典)
Posted ShenLiang2025
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了SQL基础操作_3_数据字典(涵盖SQL ServerOracleMysql常见系统数据字典)相关的知识,希望对你有一定的参考价值。
目录
数据库元数据查询
注:数据集和表结构见 SQL基础操作_1_检索数据7.5.1 列出模式中所有的表
需求:查询给定模式下创建的所有表和创建时间。
解决方法:通过各个数据库里提供的系统视图查询。
Sql Server:
USE Shenl;
GO
SELECT TABLE_NAME FROM INFORMATION_SCHEMA.tables
WHERE TABLE_TYPE='BASE TABLE'
或:
SELECT NAME as table_name FROM SYSOBJECTS WHERE XTYPE='U' ORDER BY NAME
或:
SELECT name as table_name,create_date as create_time FROM [sys].[all_objects]
WHERE type='U' AND is_ms_shipped=0
ORDER BY NAME
执行结果:
Database_Name | Create_time |
master | 2003-04-08 09:13:36.390 |
tempdb | 2017-04-16 09:36:02.723 |
model | 2003-04-08 09:13:36.390 |
msdb | 2014-02-20 20:49:38.857 |
ReportServer | 2017-03-19 09:58:21.533 |
ReportServerTempDB | 2017-03-19 09:58:22.640 |
AdventureWorks2014 | 2017-03-19 15:34:10.683 |
AdventureWorksDW2014 | 2017-03-19 15:39:02.770 |
Shenl | 2017-04-11 12:57:23.723 |
Mysql:
use shenl;
SELECT TABLE_NAME,CREATE_TIME,TABLE_COMMENT FROM INFORMATION_SCHEMA.tables
WHERE TABLE_TYPE='BASE TABLE' AND TABLE_SCHEMA='shenl'
ORDER BY TABLE_COMMENT DESC
执行结果:
TABLE_NAME | CREATE_TIME | TABLE_COMMENT |
emp | 2017/4/16 9:14:40 | 雇员表 |
dept | 2017/4/16 9:14:39 | 部门表 |
salgrade | 2017/4/16 9:14:41 | 工资等级表 |
bonus | 2017/4/16 9:14:41 | 奖金表 |
Oracle:
SELECT TABLE_NAME FROM USER_TABLES;
SELECT TABLE_NAME FROM ALL_TABLES
WHERE OWNER='SHENL;
SELECT OBJECT_NAME ,CREATED
FROM ALL_OBJECTS
WHERE OBJECT_TYPE='TABLE'
AND OWNER='SHENL'
ORDER BY CREATED DESC
执行结果:
table_name | create_time |
TMP_V | 2017/3/31 18:49:06 |
SALGRADE | 2017/3/27 15:25:47 |
BONUS | 2017/3/27 15:25:47 |
DEPT | 2017/3/27 15:25:46 |
EMP | 2017/3/27 15:25:44 |
7.5.2 列出所有的数据库
需求:查询给当前数据库实例下所有的数据库名和创建时间。
解决方法:通过各个数据库里提供的与数据库相关的数据字典进行查询。
SqlServer:
SELECT NAME AS Database_Name,create_date AS Create_time
FROM sys.databases
执行结果:
Database_Name | Create_time |
master | 2003-04-08 09:13:36.390 |
tempdb | 2017-04-16 09:36:02.723 |
model | 2003-04-08 09:13:36.390 |
msdb | 2014-02-20 20:49:38.857 |
ReportServer | 2017-03-19 09:58:21.533 |
ReportServerTempDB | 2017-03-19 09:58:22.640 |
AdventureWorks2014 | 2017-03-19 15:34:10.683 |
AdventureWorksDW2014 | 2017-03-19 15:39:02.770 |
Shenl | 2017-04-11 12:57:23.723 |
Oracle:
Oracle里的数据库概念跟Sql Server略有不同,oracle里一个数据库对应多个实例,当然在Sql Server里也可以安装多个实例。不过一般不这么做。Oralce里的用户类似于Sql Server里的数据库,即一个用户下可能会有很多表。所以当前命题可以查询当前实例里的用户名。
注: 这里关于oracle的数据库、数据库实例、表空间、表、用户没有做过多的展开。简单的说一个数据库可以对应多个数据库实例,而一个数据库实例对应多个表空间,每个表空间对应多个用户和数据库文件。一个用户可以创建多个表。见下图示意:
select name from v$database;
select USERNAME,Created AS Create_time from dba_users;
执行结果:
USERNAME | Create_time |
Sys | 2003-04-08 09:13:36.390 |
Scott | 2003-04-16 09:36:02.723 |
Shenl | 2003-04-08 09:13:36.390 |
… | … |
注:
1 oralce数据库、实例、表空间、用户、表分析参考来源 http://blog.csdn.net/haiross/article/details/20357675
2 用户数据较多,这里用…省略。
Mysql:
show databases
-- 或
SELECT SCHEMA_NAME FROM information_schema.SCHEMATA
执行结果:
SCHEMA_NAME |
information_schema |
performance_schema |
shenl |
7.5.3 列出给定表的基本信息
需求:查询出给定的表dept,emp,bonus,salgrade里的表名,字段名、字段类型、字段注释、表注释信息。
解决方法:通过各个数据库里提供的与数据库相关的数据字典进行查询。
Oracle:
SELECT B.TABLE_NAME,B.COLUMN_NAME,B.DATA_TYPE,A.COMMENTSAS Table_Comm ,C.COMMENTSASColumn_Comm
from user_tab_comments A
JOIN user_tab_columns B
ON A.TABLE_NAME = B.TABLE_NAME
JOIN user_col_comments C
ON B.TABLE_NAME = C.TABLE_NAME AND B.COLUMN_NAME = C.COLUMN_NAME
WHERE A.TABLE_NAME IN ('DEPT','EMP','BONUS','SALGRADE')
Mysql:
SELECT A.TABLE_NAME,A.COLUMN_NAME,A.DATA_TYPE,B.TABLE_COMMENTAS Table_Comm,A.COLUMN_COMMENT AS Column_Comm
FROM INFORMATION_SCHEMA.COLUMNS A
JOIN INFORMATION_SCHEMA.TABLES B
ON A.TABLE_NAME = B.TABLE_NAME
WHERE A.TABLE_SCHEMA='SHENL'
AND A.TABLE_NAME IN('DEPT','EMP','BONUS','SALGRADE')
SqlServer:
USE Shenl;
GO
SELECT
A.name AS table_name,
B.name AS column_name,
C.name AS data_type,
D.value AS column_comm
FROM sys.tables A
INNER JOIN
(
SELECT B.object_id,NULL AS name,NULL AS user_type_id,0 as column_id FROMsys.tables A
INNER JOIN sys.columns B
ON B.object_id= A.object_id
WHERE A.name IN ('dept','emp','bonus','salgrade') AND column_id = 1
UNION
SELECT object_id,name,user_type_id,column_id FROM sys.columns
)B
ON B.object_id= A.object_id
LEFT JOIN sys.systypes C
ON B.user_type_id= C.xtype
INNER JOIN sys.extended_properties D
ON D.major_id= B.object_id AND
D.minor_id = B.column_id
WHERE A.name IN ('dept','emp','bonus','salgrade')
ORDER BY A.name
-- 或:
USE Shenl;
GO
SELECT table_name,column_name,data_type,column_comm,F.value as table_comm FROM
(
SELECT A.object_id AS Object_id,
A.name AS table_name,
B.name AS column_name,
C.name AS data_type,
D.value AS column_comm
FROM sys.tables A
INNER JOIN sys.columns B
ON B.object_id= A.object_id
LEFT JOIN sys.systypes C
ON B.user_type_id= C.xtype
INNER JOIN sys.extended_properties D
ON D.major_id= B.object_id AND
D.minor_id = B.column_id
WHERE A.name IN ('dept','emp','bonus','salgrade')
)E
JOIN
(
SELECT major_id,value FROM sys.extended_propertiesA
JOIN sys.tables B
ON A.major_id= B.object_id
AND B.name IN ('dept','emp','bonus','salgrade') AND A.minor_id = 0
)F
ON E.object_id= F.major_id
执行结果:
table_name | column_name | data_type | column_comm | table_comm |
dept | deptno | int | 部门编号 | 部门表 |
dept | dname | varchar | 部门名称 | 部门表 |
dept | loc | varchar | 部门所在位置 | 部门表 |
emp | empno | int | 雇员编号 | 雇员表 |
emp | ename | varchar | 雇员名称 | 雇员表 |
emp | job | varchar | 雇员职位 | 雇员表 |
emp | mgr | int | 雇员对应的领导的编号 | 雇员表 |
emp | hiredate | date | 雇员的雇佣日期 | 雇员表 |
emp | sal | decimal | 雇员的基本工资 | 雇员表 |
emp | comm | decimal | 奖金 | 雇员表 |
emp | deptno | int | 所在部门 | 雇员表 |
salgrade | grade | int | 工资等级 | 工资等级表 |
salgrade | losal | int | 此等级的最低工资 | 工资等级表 |
salgrade | hisal | int | 此等级的最高工资 | 工资等级表 |
bonus | ename | varchar | 雇员姓名 | 奖金表 |
bonus | job | varchar | 雇员职位 | 奖金表 |
bonus | sal | decimal | 雇员工资 | 奖金表 |
bonus | comm | decimal | 雇员资金 | 奖金表 |
注:
1 sql server里的第一种实现方式是将表的注释作为一行,其它字段如(column_name、data_type)均以NULL值显示。
2 如果不了解各个数据库的注释方式,如下做个简单示例:
Oracle:
comment on table EMP is '雇员表';
comment on column EMP.EMPNO is '雇员的编号,由四位数字所组成';
Sql Server:
sql server里的注释存储在系统表sys.extended_properties中,一般我们通过调用存储过程sp_addextendedproperty来对表和字段加注释。
EXECUTE sp_addextendedproperty N'MS_Description',N'奖金表',N'user',N'dbo',N'table',N'bonus',NULL,NULL
EXECUTE sp_addextendedproperty N'MS_Description',N'雇员姓名',N'user',N'dbo',N'table',N'bonus',N'column',N'ename'
Mysql:
ALTER TABLE `EMP` COMMENT '雇员表';
ALTER TABLE `EMP` MODIFY COLUMN `empno` COMMENT '雇员编号';
7.5.4 列出给定表的索引信息
需求:查询出给定的表emp的索引信息。
解决方法:通过各个数据库里提供的与索引相关的数据字典进行查询。
Oracle:
CREATE INDEX Idx_EMP_EMPNO ON EMP(EMPNO);
SELECT table_name,index_name,column_name,column_position
FROM sys.all_ind_columns
WHERE table_name ='EMP'
ANDtable_owner='SHENL';
执行结果:
TABLE_NAME | INDEX_NAME | COLUMN_NAME | COLUMN_POSITION |
EMP | IDX_EMP_EMPNO | EMPNO | 1 |
Sql Server:
SELECT a.name AS table_name,
b.name AS index_name,
d.name AS column_name,
c.index_column_id
FROM sys.tables a,sys.indexes b,sys.index_columns c,sys.columns d
WHERE a.object_id= b.object_id
AND b.object_id= c.object_id
AND b.index_id= c.index_id
AND c.object_id= d.object_id
AND c.column_id= d.column_id
AND a.name='EMP'
执行结果:
table_name | index_name | column_name | index_column_id |
emp | PK__emp__AF4C318A634F478A | empno | 1 |
Mysql:
show indexfrom emp;
7.5.5 列出给定表的主键、外键约束
需求:查询出给定的表emp的外键约束信息。
解决方法:通过各个数据库里提供的与外键约束相关的数据字典进行查询。
SqlServer:
SELECT a.table_name,
a.CONSTRAINT_NAME,
b.COLUMN_NAME,
a.CONSTRAINT_TYPE
FROM information_schema.table_constraints a,
information_schema.key_column_usage b
WHERE a.table_name='EMP'
-- AND a.table_schema='SHENL'
AND a.table_name= b.table_name
AND a.table_schema= b.table_schema
AND a.constraint_name= b.constraint_name
执行结果:
table_name | CONSTRAINT_NAME | COLUMN_NAME | CONSTRAINT_TYPE |
emp | FK__emp__deptno__38996AB5 | deptno | FOREIGN KEY |
emp | PK__emp__AF4C318A634F478A | empno | PRIMARY KEY |
如果只是查主键信息可以:
SELECT
tab.name AS table_name,
idx.name AS pk_name,
col.name AS column_name
FROM
sys.indexes idx
JOIN sys.index_columns idxCol
ON idx.object_id= idxCol.object_id
AND idx.index_id=idxCol.index_id
AND idx.is_primary_key= 1
JOIN sys.tables tab
ON idx.object_id= tab.object_id
JOIN sys.columns col
ON idx.object_id= col.object_id
AND idxCol.column_id=col.column_id
AND tab.name='EMP'
执行结果:
table_name | pk_name | column_name |
emp | PK__emp__AF4C318A634F478A | empno |
注:
1 如果想查唯一约束可以将上述高亮处修改为:
ANDidx.is_unique_constraint = 1。
2 默认情况下会在基于主键建立个索引。
3 这里说的主外键约束对应constraint,一般包括PK、FK、UK即主键、外键、唯一键。而约束一般指的是default、check即默认值约束、检查约束。
Mysql:
SELECT CONSTRAINT_NAME,TABLE_NAME,COLUMN_NAME,
REFERENCED_TABLE_NAME,
REFERENCED_COLUMN_NAME
FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE
WHERE TABLE_SCHEMA='SHENL'
AND TABLE_NAME IN('emp')
Oracle:
SELECT A.CONSTRAINT_NAME,A.TABLE_NAME,A.COLUMN_NAME,B.CONSTRAINT_TYPE
FROM USER_CONS_COLUMNS A,USER_CONSTRAINTS B
WHERE A.CONSTRAINT_NAME =B.CONSTRAINT_NAME
AND B.CONSTRAINT_TYPEIN('P','R')
AND A.TABLE_NAME ='EMP'
7.5.6 列出给定表的外键引用
需求:查询出给定的表emp的外键约束信息。
解决方法:通过各个数据库里提供的与外键约束相关的数据字典进行查询。
SqlServer:
SELECT
RefObj.name AS RefTab_Name,
fk.name AS Fk_Name,
RefCol.name AS RefTab_Column_Name,
RefedObj.name AS RefedTab_Name,
RefedCol.name AS RefedTab_Column_Name
FROM sys.foreign_keys fk
JOIN sys.all_objects RefObj
ON fk.parent_object_id= RefObj.object_id
JOIN sys.all_objects RefedObj
ON fk.referenced_object_id=RefedObj.object_id
JOIN sys.foreign_key_columns fkCols
ON fk.object_id= fkCols.constraint_object_id
JOIN sys.columns RefCol
ON RefObj.object_id= RefCol.object_id
AND fkCols.parent_column_id=RefCol.column_id
JOIN sys.columns RefedCol
ON RefedObj.object_id= RefedCol.object_id
AND fkCols.referenced_column_id=RefedCol.column_id;
执行结果:
RefTab_Name | Fk_Name | RefTab_Column_Name | RefedTab_Name | RefedTab_Column_Name |
emp | FK__emp__deptno__38996AB5 | deptno | dept | deptno |
Mysql:
SELECT CONSTRAINT_NAME,TABLE_NAME,COLUMN_NAME,
REFERENCED_TABLE_NAME,
REFERENCED_COLUMN_NAME
FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE
WHERE TABLE_SCHEMA='SHENL' AND TABLE_NAME IN('emp') AND REFERENCED_TABLE_NAME IS NOT NULL
Oracle:
SELECT A.CONSTRAINT_NAME,A.TABLE_NAME,A.COLUMN_NAME,B.CONSTRAINT_TYPE
FROM USER_CONS_COLUMNS A,USER_CONSTRAINTS B
WHERE A.CONSTRAINT_NAME =B.CONSTRAINT_NAME
AND B.CONSTRAINT_TYPEIN('R')
AND A.TABLE_NAME ='EMP'
7.5.7 列出给定表的检查约束
需求:查询出给定的表emp的检查约束(check)信息。
解决方法:通过各个数据库里提供的与检查约束(check)相关的数据字典进行查询。
SqlServer:
-- 新增check约束以检查emp表的enmae字段长度不超过16
ALTER TABLE EMP DROP CONSTRAINT CK_Emp_Ename;
ALTER TABLE EMP ADD CONSTRAINT CK_Emp_Ename CHECK(LEN(ename)<16);
SELECT A.name AS CKConstraint_Name,
B.name AS Table_Name,
C.name AS CKConstraint_ColumnName,
A.definition AS DF_Def,
A.create_date AS Create_time,
A.modify_date AS Modify_time
FROM sys.check_constraints A
JOIN sys.tables B
ON A.parent_object_id= B.object_id
JOIN sys.columns C
ON B.object_id= C.object_idAND A.parent_column_id= C.column_id
执行结果:
CKConstraint_Name | Table_Name | CKConstraint_ColumnName | DF_Def | Create_time | Modify_time |
CK_Emp_Ename | emp | ename | (len([ename])<(16)) | 2017-04-19 10:17:41.640 | 2017-04-19 10:17:41.640 |
Mysql:
ALTER TABLE EMP ADD CONSTRAINT CK_Emp_Ename CHECK (LEN(ename)<16);
注;Mysql数据字典里没有存check约束,所以暂时无法查阅。
Oracle:
ALTER TABLE EMP ADD CONSTRAINT CK_Emp_Ename CHECK (LENGTH(ename)<15);
SELECT A.CONSTRAINT_NAME,A.TABLE_NAME,A.COLUMN_NAME,B.CONSTRAINT_TYPE
FROM USER_CONS_COLUMNS A,USER_CONSTRAINTS B
WHERE A.CONSTRAINT_NAME =B.CONSTRAINT_NAME
AND B.CONSTRAINT_TYPEIN('C')
AND A.TABLE_NAME ='EMP'
7.5.8 列出给定表的默认约束
需求:查询出给定的表emp的默认约束(default)信息。
解决方法:通过各个数据库里提供的与默认约束(default)相关的数据字典进行查询。
SqlServer:
-- 新增default约束以设置emp表的comm默认值是0
alter table EMP drop constraint DF_EMP_Comm;
alter table EMP add constraint DF_EMP_Comm DEFAULT((0)) for comm;
alter table EMP with check add constraint DF_EMP_Comm DEFAULT((0)) for comm;
alter table EMP with nocheck add constraint DF_EMP_Comm DEFAULT((0)) for comm;
SELECT A.name AS DFConstraint_Name,
B.name AS Table_Name,
C.name AS DFConstraint_ColumnName,
A.definition AS DF_Def,
A.create_date AS Create_time,
A.modify_date AS Modify_time
FROM sys.default_constraints A
JOIN sys.tables B
ON A.parent_object_id= B.object_id
JOIN sys.columns C
ON B.object_id= C.object_id AND A.parent_column_id= C.column_id;
执行结果:
DFConstraint_Name | Table_Name | DFConstraint_ColumnName | DF_Def | Create_time | Modify_time |
DF_EMP_Comm | emp | comm | ((0)) | 2017-04-19 09:24:14.050 | 2017-04-19 09:24:14.050 |
Mysql:
SELECT TABLE_NAME,COLUMN_NAME,COLUMN_DEFAULT
FROM information_schema.columns
WHERE TABLE_NAME = 'EMP'
AND column_default IS NOT NULL
Oracle:
alter table EMP modify comm default 0;
SELECT t.COLUMN_NAME,
t.nullable,
t.data_default
FROM USER_TAB_COLS t
WHERE TABLE_NAME ='EMP'
AND data_default IS NOT NULL
7.5.9 列出给定表的所有约束
需求:查询出给定的表emp的相关的约束信息。
解决方法:通过各个数据库里提供的与约束相关的数据字典进行查询。
SqlServer:
SELECT B.name AS Constraint_Name,
B.type,
CASE B.type WHEN 'PK' THEN '主键'
WHEN 'F'THEN '外键'
WHEN 'D'THEN '默认值约束'
WHEN 'C'THEN '检查约束' END AS ConstaintType_Desc,
CASE B.type WHEN 'PK' THEN G.COLUMN_NAME
WHEN 'F' THEN G.COLUMN_NAME
WHEN 'D' THEN E.name
WHEN 'C' THEN F.name END AS Column_name,
CASE B.type WHEN 'PK' THEN NULL
WHEN 'F' THEN NULL
WHEN 'D' THEN C.definition
WHEN 'C' THEN D.definition END AS Define,
B.create_date AS Create_Time,
B.modify_date AS Modify_Time
FROM sys.all_objects A
JOIN sys.all_objects B
ON A.object_id= B.parent_object_id
JOIN sys.default_constraints C
ON B.parent_object_id= B.parent_object_id
JOIN sys.check_constraints D
ON B.parent_object_id= D.parent_object_id
JOIN sys.all_columns E
ON E.object_id= C.parent_object_id
AND C.parent_column_id= E.column_id
JOIN sys.all_columns F
ON F.object_id= D.parent_object_id
AND D.parent_column_id= F.column_id
LEFT JOIN information_schema.key_column_usage G
ON B.name= G.CONSTRAINT_NAME
WHERE A.NAME='EMP'
执行结果:
Constraint_Name | type | ConstaintType_Desc | Column_name | Define | Create_Time | Modify_Time |
PK__emp__AF4C318A634F478A | PK | 主键 | empno | NULL | 2017-03-27 16:27:00.583 | 2017-03-27 16:27:00.583 |
FK__emp__deptno__38996AB5 | F | 外键 | deptno | NULL | 2017-03-27 16:27:00.583 | 2017-03-27 16:27:00.583 |
DF_EMP_Comm | D | 默认值约束 | comm | ((0)) | 2017-04-19 09:24:14.050 | 2017-04-19 09:24:14.050 |
CK_Emp_Ename | C | 检查约束 | ename | (len([ename])<(16)) | 2017-04-19 10:17:41.640 | 2017-04-19 10:17:41.640 |
注:
sys.all_objects里的type的枚举类型有如下:
执行结果:
type | 数据库对象类型 |
AF | 聚合函数(CLR) |
C | CHECK约束 |
D | DEFAULT(约束或独立) |
F | FOREIGNKEY约束 |
PK | PRIMARYKEY约束 |
P | SQL存储过程 |
PC | 程序集(CLR)存储过程 |
FN | SQL标量函数 |
FS | 程序集(CLR)标量函数 |
FT | 程序集(CLR)表值函数 |
R | 规则(旧式,独立) |
RF | 复制筛选过程 |
SN | 同义词 |
SQ | 服务队列 |
TA | 程序集(CLR)DML触发器 |
TR | SQLDML触发器 |
IF | SQL内联表值函数 |
TF | SQL表值函数 |
U | 表(用户定义类型) |
UQ | UNIQUE约束 |
V | 视图 |
X | 扩展存储过程 |
IT | 内部表 |
注:数据库对象类型这列为自己添加的备注。
Mysql:注意mysql内并无同一视图可以满足上述需求。
Oracle:
SELECT A.CONSTRAINT_NAME,A.TABLE_NAME,A.COLUMN_NAME,B.CONSTRAINT_TYPE
FROM USER_CONS_COLUMNS A,USER_CONSTRAINTS B
WHERE A.CONSTRAINT_NAME =B.CONSTRAINT_NAME
AND A.TABLE_NAME ='EMP'
7.5.10 列出数据库里的所有对象
需求:查询出给定的数据库里的所有对象的信息。
解决方法:通过各个数据库里提供的数据对象相关的数据字典进行查询。
SqlServer:
SELECT name,object_id,parent_object_id,type,type_desc,create_date,modify_date
FROM sys.all_objects
WHERE is_ms_shipped = 0
执行结果:
name | object_id | parent_object_id | type | type_desc | create_date | modify_date |
tb_marketrecommlog | 245575913 | 0 | U | USER_TABLE | 2017-03-25 15:05:20.850 | 2017-03-25 15:05:20.850 |
dept | 885578193 | 0 | U | USER_TABLE | 2017-03-27 16:27:00.580 | 2017-03-27 16:27:00.583 |
PK__dept__BE2C337D15A7E7E3 | 901578250 | 885578193 | PK | PRIMARY_KEY_CONSTRAINT | 2017-03-27 16:27:00.580 | 2017-03-27 16:27:00.580 |
emp | 917578307 | 0 | U | USER_TABLE | 2017-03-27 16:27:00.580 | 2017-04-19 10:17:41.640 |
PK__emp__AF4C318A634F478A | 933578364 | 917578307 | PK | PRIMARY_KEY_CONSTRAINT | 2017-03-27 16:27:00.583 | 2017-03-27 16:27:00.583 |
FK__emp__deptno__38996AB5 | 949578421 | 917578307 | F | FOREIGN_KEY_CONSTRAINT | 2017-03-27 16:27:00.583 | 2017-03-27 16:27:00.583 |
salgrade | 965578478 | 0 | U | USER_TABLE | 2017-03-27 16:27:00.590 | 2017-03-27 16:27:00.590 |
bonus | 981578535 | 0 | U | USER_TABLE | 2017-03-27 16:27:00.593 | 2017-03-27 16:27:00.593 |
tmp_v | 1557580587 | 0 | V | VIEW | 2017-04-12 10:44:00.703 | 2017-04-12 10:44:00.703 |
translate | 1573580644 | 0 | FN | SQL_SCALAR_FUNCTION | 2017-04-12 10:51:52.840 | 2017-04-12 10:51:52.840 |
DF_EMP_Comm | 1877581727 | 917578307 | D | DEFAULT_CONSTRAINT | 2017-04-19 09:24:14.050 | 2017-04-19 09:24:14.050 |
CK_Emp_Ename | 1893581784 | 917578307 | C | CHECK_CONSTRAINT | 2017-04-19 10:17:41.640 | 2017-04-19 10:17:41.640 |
f_splitSTR | 1909581841 | 0 | TF | SQL_TABLE_VALUED_FUNCTION | 2017-04-19 11:25:32.807 | 2017-04-19 11:25:32.807 |
Mysql:暂无相关视图可以满足此需求。
Oracle:
SELECT OBJECT_NAME,OBJECT_TYPE
FROM DBA_OBJECTS
WHERE OWNER=UPPER('SHENL')
以上是关于SQL基础操作_3_数据字典(涵盖SQL ServerOracleMysql常见系统数据字典)的主要内容,如果未能解决你的问题,请参考以下文章