ddl dml dcl
DCL数据控制语言
创建临时表空间
create temporary tablespace user_temp
tempfile 'E:/oracle/product/10.1.0/oradata/orcl/user_temp.dbf'
size 50m
autoextend on
next 32m maxsize 2048m
extent management local;
创建用户表空间
CREATE TABLESPACE tbs_sns_idx
LOGGING
DATAFILE 'E:/oracle/product/10.1.0/oradata/orcl/tbs_sns_idx.dbf'
SIZE 32M
AUTOEXTEND ON
NEXT 32M MAXSIZE 2048M
EXTENT MANAGEMENT LOCAL;
创建用户
create user 用户名 identified by 密码;
授权
grant 权限1,权限2,... to 用户名
范例:将创建session的权限给test用户
grant create session to test;
实际上一个新的用户所有的权限都要分别赋予,如果现在假设要想把多个权限一次性赋予一个用户,则可以将这些权限定义成一组角色。
在Oracle中提供两个主要角色:connect,resource,可以直接把这2个角色赋予test用户。
范例:
grant connect,resource to test;
可在创建用户的同时指定表空间[不指定的话,默认为USERS这个表空间]
create user 用户名 identified by 密码 default tablespace tbs_sns_idx TEMPORARY TABLESPACE user_temp;
查看用户表空间使用情况
select username,default_tablespace from dba_users;
修改用户的密码
alter user 用户名 identifiyed by 新的密码;
在一般的系统中,在用户第一次登陆的时候可以修改密码,要想完成此功能,可以手工让一个密码失效,格式如下:
alter user 用户名 password expire;
则用户第一次登陆时会有个提示框修改密码。
锁住用户
alter user 用户名 account lock;
解锁用户
alter user 用户名 account unlock;
给test用户查询与删除scott用户的emp表的权利
grant select,delete on scott.emp to test;
回收权限
revoke 权限 on 用户.表名 from 用户;
范例:回收test用户的select及delete权限
revoke select,delete on scott.emp from test;
DDL数据定义语言
创建表
create table person(
pid varchar2(18),
name varchar2(200),
age number(3),
birthday date,
sex varchar(2) default'男'
);
增加address字段
alter table person add (address varchar(200) default '暂无地址')
修改name字段
alter table person modify (name varchar2(20) default '无名氏')
删除表
drop table person
截断表[清空一张表的数据,可立即释放资源,无法回滚。]
truncate table person
创建主键约束,非空约束,唯一约束,检查约束
create table person(
pid varchar2(18),
name varchar2(200) unique not null,
age number(3) not null,
birthday date,
sex varchar2(2) default'男',
constraint person_pid_pk primary key(pid),
constraint person_name_uk unique(name),
constraint person_age_ck check(age between 0 and 150),
constraint person_sex_ck check(sex in ('男','女'))
);
创建外键约束
create table book(
bid number,
bname varchar2(30),
bprice number(5,2),
pid varchar2(18),
constraint book_bid_pk primary key(bid),
constraint person_book_pid_fk foreign key(pid) references person(pid) [on delete cascade]
);
如果是表创建完后再添加约束
alter table person add constraint person_pid_pk primary key(pid);
alter table person add constraint person_name_uk unique(name);
alter table person add constraint person_age_ck check(age between 0 and 150);
alter table person add constraint person_sex_ck check(sex in ('男','女'));
alter table book add constraint book_bid_pk primary key(bid);
alter table book add constraint person_book_pid_fk foreign key(pid) references person(pid) on delete cascade;
删除约束
alter table person drop constraint 约束名;
创建视图
create or replace view 视图名 as 子查询 [with read only]
create or replace view empv20 as select empno,ename,job,hiredate from emp where deptno = 20;
删除视图
drop view empv20
创建序列
create sequence 序列名
[increment by n][start with n]
[{maxvalue n|nomaxvalue}]
[{minvalue n|nominvalue}]
[{cycle|nocycle}]
[{cache n|nocache}];
nextval:取得序列的下一个值
currval:取得序列的当前值
create sequence seq_pid;
insert into person(pid) values(seq_pid.nextval);
同义词
create synonym emp from scott.emp;
sys用户访问scott下的emp表:
select * from scott.emp;
创建同义词后:
select * from emp;即可
删除同义词
drop synonym emp;
DML数据操作语言
主要是SQL结构化查询语言及INSERT,UPDATE,DELETE的操作
SQLPLUSW基本命令
设置行显示长度:set linesize 长度
设置页显示行数:set pagesize 行数
ed,@,/
conn 用户名/密码 [as sysdba]
show user
数据库的备份与恢复
exp imp命令的使用
数据库设计三范式
第一范式:各属性只包含原子值,不可再分
第二范式:没有部分函数依赖
第三范式:没有传递函数依赖
修改Oracle的8080端口
- call dbms_xdb.cfg_update(updateXML(dbms_xdb.cfg_get(),'/xdbconfig/sysconfig/protocolconfig/httpconfig/http-port/text()',9000))
ddl dml dcl的更多相关文章
- SQL语言:DDL,DML,DCL,DQL,TCL
DDL(Data Definition Language)数据库定义语言 statements are used to define the database structure or schema. ...
- DDL DML DCL SQL
https://dev.mysql.com/doc/refman/5.7/en/glossary.html#glos_ddl SQL The Structured Query Language tha ...
- 什么是DDL,DML,DCL
转载自 https://www.2cto.com/database/201610/555167.html DML.DDL.DCL区别 . 总体解释: DML(data manipulation la ...
- DDL DML DCL语句
总体解释:DML(data manipulation language):自动提交的数据库操作语言 它们是SELECT.UPDATE.INSERT.DELETE,就象它的名字一样 DDL( ...
- 数据库必会必知 之 SQL四种语言:DDL DML DCL TCL
作者:泥瓦匠 今天群里面讨论,DDL 还是 DML,我这种小白还是总结下他们的区别吧. 1. DDL - Data Definition Language 数据库定义语言:定义数据库的结构. 其主要命 ...
- 数据库必会必知 之 SQL四种语言:DDL DML DCL TCL(转)
今天群里面讨论,DDL 还是 DML,我这种小白还是总结下他们的区别吧. 1. DDL – Data Definition Language 数据库定义语言:定义数据库的结构. 其主要命令有CREAT ...
- SQL四种语言:DDL,DML,DCL,TCL
1.DDL(Data Definition Language)数据库定义语言statements are used to define the database structure or schema ...
- DDL\DML\DCL\DQL
[DML] DML = Data Manipulation Language,数据操纵语言,命令使用户能够查询数据库以及操作已有数据库中的数据的计算机语言.具体是指是UPDATE更新.INSERT插入 ...
- DDL DML DCL TCL之不同
http://www.orafaq.com/faq/what_are_the_difference_between_ddl_dml_and_dcl_commands DDL Data Definiti ...
随机推荐
- Array基本操作
// defined array object val arr0= ) val arr1= Array(") println(arr1()) arr1()="Hello Spark ...
- Eclipse in Ubuntu16.04LTS Final Beta
#2016.03.30 在虚拟机Ubuntu16.04LTS上,用Eclipse编写运行Java,就目前而言,实在不是明智之举.卡顿极其厉害,还是在物理机上运行吧.那么继续Ubuntu的探索历程. 用 ...
- 循环生成sql文件。
package com; import java.io.File; import java.io.FileWriter; import java.io.IOException; import java ...
- SSH三大框架的工作原理及流程
Hibernate工作原理及为什么要用? 原理:1.通过Configuration().configure();读取并解析hibernate.cfg.xml配置文件2.由hibernate.cfg.x ...
- Ajax请求中的async:false/true的作用
async: false,(默认是true);false为同步,Ajax请求将整个浏览器锁死,只有tet.php执行结束后,才可以执行其它操作. 当async: true 时,ajax请求是异步的.但 ...
- C语言通用双向循环链表操作函数集
说明 相比Linux内核链表宿主结构可有多个链表结构的优点,本函数集侧重封装性和易用性,而灵活性和效率有所降低. 可基于该函数集方便地构造栈或队列集. 本函数集暂未考虑并发保护. 一 ...
- :selected
描述: 查找所有选中的选项元素 HTML 代码: <select> <option value="1">Flowers</option> < ...
- mysql5.6版本开启数据库查询日志方法
在my.ini中的[mysqld]下添加了以下两行代码: general_log=ONgeneral_log_file = c:/mysql.log 这个log文件是可以用文本编辑工具如editplu ...
- TortoiseGit 连接每次都要输入用户名和密码
当你配置好git后,在C:\Documents and Settings\Administrator\ 或者 C:\Users\Administrator 目录下有一个 .gitconfig 的文件 ...
- linux centos 6.5 运行MySQL Workbench 6.0找不到 libmysqlclient.so.16和libmysqlclient_r.so.16
找到已安装mysql/lib目录下有类似文件: -rw-r--r-- root root 12月 : libmysqlclient.a lrwxrwxrwx root root 12月 : libmy ...