Oracle SQL 071-1
各种DB如Oracle/SQLserver/MySQL因为特色虽遵守ISO标准但不兼容
SQL(Structured Query Language)
DDL (Data Definition Language,对对象Object的增删改查ADCL)
DML (Data Manipulation Language,对数据类型的ADCL语句)
DCL(Data Control Language,对用户角色权限语句)
一、DDL中对象类型(常见类型:有table\index\constraint\view\synonym\sequence)
所有对象:select count(count(object_type)) from dba_objects group by object_type;48
能访问对象:select count(count(object_type)) from all_objects group by object_type;27
拥有的对象:select count(count(object_type)) from user_objects group by object_type;7
所有表:select count(*) from dba_tables;2189
能访问的表:select count(*) from all_tables;171
拥有的表:select count(*) from user_tables;56
所有表列:select count(*) from dba_tab_columns;114607
能访问的表列:select count(*) from all_tab_columns;23733
拥有的表列:select count(*) from user_tab_columns;755
create table a1_$#(a date);select count(*) from user_tables where table_name='A1_$#'; 1
select count(*) from user_tables where table_name='a1_$#' ;0 不过desc 表名是不分大小写的
考点:对象名称可字母数字下划线$#,自动转大写
有版本是对象长度30,desc看sys.obj$z中name的长度128和desc user_tables中的table_name长度128,实测表名长是128,目前我版本是18c
二、DDL中对象名称空间
(常见类型:有table\index\constraint\view\synonym\sequence)
在同一模式中,同一名称空间下不能同名
共享了名称空间的常用对象有(table\view\synonym\sequence)
如create view a1_$# as select * from A1_$#;提示ORA-00955: name is already used by an existing object
有独立名称空间的有(constraint\index\trigger\dblink等),虽然这些可以和其它对象同名但现实不建议
三、DML中表数据类型
desc 对象名(不分大小写)
NUMBERnumber(precision精度,scale刻度)没有指定precision和scale,默认1-38,-84至127
1、P-S大于0时是整数位长的限制,小数部分超S长会自动舍入,整数部分超P-S会报错,若小数位舍入有进位导致整数长度超P-S也会报错。
2、P-S小于等于0时,整数部分只能是0,S是最终存储的小数点后的长度超长会进行取舍,P是右边非0的数字长度限制,如果舍入后导致最右非0的长度超过P会报错;
3、整数部分不是0时,若S>0,小数点右S长度进行舍入;S<0时小数点向左归S个0长度舍入;
DATE定义输入
CHAR