SQL 基本定义

来源:互联网 发布:广度优先算法 a星算法 编辑:程序博客网 时间:2024/04/30 01:22

SQL的几种语言   

一:数据定义语言(DLL) 主要用来生成,修改,删除对象,表,视图,用户自定义数据类型。
  Create Database Test 
  Create table Test 
  Create view Test 
  create sequence,constraint,index 
  alter table,index,sequence,constraint 
  drop table Test,drop pk_id_tab, 


二:数据操纵语言(DML) 用来操纵数据库中的数据
  Insert into Test() values() 
  select * from 
  update Test set lastName=""where 
  delete Test where 
三:数据控制语言(DCL) 主要是用来设置和修改权限    
  Grant select ON Test to public  public:角色  授予所有用户查询权限 
  deny delete ON Test to public 拒绝公共用户从数据库中删除数据权限
                Grant cdl to DBA;     

几个区别:       
(1)、insert into Test(field1,field2) values() 注意:Test已经存在,且每次只添加一列
(2)、insert…select :将实现将一个表或多个表中的数据添加到某个表中的功能       
insert Test select * from Test1 将Test1中的数据添加到Test中,且保证两个表的数据类型和字段一致.

(3)、select …into:向一个新表中添加数据的操作       
select * into NewTest from Test where 新建了一个NewTest,* 是新表的列。from 数据来源

原创粉丝点击