资讯详情

数据库语言(DDL,DML,DQL,DCL)

DDL语句不用commit

语言的数据定义DDL用于在数据库中创建各种对象-表、视图、索引、同义词、聚集等。 CREATE TABLE(表)/VIEW(视图)/INDEX(索引)/SYN(同义词)/CLUSTER(簇)

1、创建(create):create index,create tablespace……

2、删除(drop,truncate):truncate删除整个数据,drop删除整个表(数据) 两者都不需要表结构commit,也不能回滚

3、修改(alter):alter table,alter database,alter tablespace……

4、查看(show,desc),show parameter(查看参数值),desc 对象-检查对象的结构

需要commit

1、插入(insert)

insert into table1(field1,field2) values(value1,value2) 

2、更新(update)

UPDATE table1 SET field1 = value1 WHERE field2 = value2 

3、删除(delete):delete只删除数据,可以回滚

delete from table1 where 范围更新:update table1 set field1=value1 where 范围 

语言的数据控制DCL用于授予或回收访问数据库的特权,并控制它 监控数据库操纵事务的时间和效果。

1、授权(grant):grant create session to scott

2、回滚(rollback)

3、提交(commit)

4、新建用户(create user)

数据查询语言DQL基本结构是由SELECT子句,FROM子句,WHERE子句组成的查询块: SELECT <字段名表> FROM <表或视图名> WHERE <查询条件>

选择:

select * from table1 where 范围 

查找:

select * from table1 where field1 like ’%value1%’  

排序:

select * from table1 order by field1,field2 desc 

总数:

select count(*) as totalcount from table1 

求和:

select sum(field1) as sumvalue from table1 

平均:

select avg(field1) as avgvalue from table1 

最大:

select max(field1) as maxvalue from table1 

最小:

select min(field1) as minvalue from table1

A: UNION 运算符

UNION 运算符通过将两个结果表(例如 TABLE1 和 TABLE2)取并集后消除所有重复行而派生出一个结果表。当 ALL 随 UNION 一起使用时(即 UNION ALL),不消除重复行。两种情况下,派生表的每一行不是来自 TABLE1 就是来自 TABLE2。

select id from my_user where id BETWEEN 10 and 15
union
select id from my_user where id BETWEEN 12 and 18;

结果:id 10-18

B: EXCEPT 运算符

EXCEPT运算符通过把在 TABLE1 中但不在 TABLE2 中的行并消除所有重复行而派生出一个结果表。当 ALL 随 EXCEPT 一起使用时 (EXCEPT ALL),不消除重复行。

select id from my_user where id BETWEEN 10 and 15
except
select id from my_user where id BETWEEN 12 and 18;

结果:id 10-11

C: INTERSECT 运算符

INTERSECT运算符通过将两个结果表 TABLE1 和 TABLE2 取交集后消除所有重复行而派生出一个结果表。当 ALL随 INTERSECT 一起使用时 (INTERSECT ALL),不消除重复行。

select id from my_user where id BETWEEN 10 and 15
intersect
select id from my_user where id BETWEEN 12 and 18;

结果:id 12-15

注:使用运算词的几个查询结果列必须是一致的。

A、left (outer) join:

左外连接(左连接):结果集既包括连接表的匹配行,也包括左连接表的所有行。

SQL:

select a.a, a.b, a.c, b.c, b.d, b.f from a LEFT OUT JOIN b ON a.a = b.c

B:right (outer) join: 右外连接(右连接):结果集既包括连接表的匹配连接行,也包括右连接表的所有行。

C:full/cross (outer) join:全外连接:不仅包括符号连接表的匹配行,还包括两个连接表中的所有记录。


转自:https://blog.csdn.net/zhaochongsi/article/details/111198636

标签: 铜铝电缆连接端子dtl

锐单商城拥有海量元器件数据手册IC替代型号,打造 电子元器件IC百科大全!

 锐单商城 - 一站式电子元器件采购平台  

 深圳锐单电子有限公司