Oracle 学习笔记day_3

Oracle 学习笔记

Day_3

/* 多表连接
内连接: 
等值连接:inner join
外连接: 
left outer jion
right outer join
Oracle 特有的写法(+)
*/

--多行查询和子查询
---获取员工的名字和部门的名字

select e.ename,d.dname from emp e,dept d where e.deptno = d.deptno ;

--子查询的方式

image-20201227193123594

/*
--创建用户
 create user 用户名
 indentified by 密码
 default tablespace 表空间的名字
 
 --但是如果用用户无权限,需要用户授权
 
  */
  create user daking 
  identified daking
  default daking
  
  --通常授予DBA的角色

image-20201227195504397*

--Oracle的 体系结构: 数据库—— 数据库实例-- 表空间 --(用户创建的表)--数据文件
--创建表表空间: 逻辑单位 , 创建一个表空间,再新建表,表空间创建用户来创建表。

image-20201227212245185

image-20201227212812307

授权:

列的类型:
varchar ,在oracle中,目前是支持的,但是不保证以后还支持
varchar2(长度)可变字符长度varchar2(10)hello 占5个字符char (长度)固定长度字符
char(10)hello占10个字符,用空格填充
number(总长度,小数长度)数字炎型
date 年月日时分秒
timestamp 时/间器,比date类型更加精确

举例如下:

create table test1(
name1 varchar2(10),
name2 char(10),
age number());

insert into test1(name1,name2) value('hello','hello');

select  * from test1 where name1 like 'hello';  -- varchar2 可变长度  不能查出结果
select  * from test1 where name1 like 'hello';  --char 可查出数据

insert into test1(age) value(2.333);

--date

select current_date from dual;   --当前时间



 

image-20201227214447729

数据类型:

long,clob: 储存 小说电影

blob : 存储电影

使用子查询的方式创创建表;

select * from scott.emp;
create table emp as select * from scott.emp;

--
/*修改表:
	添加列
	修改列vharchar2(10)删除列
	修改列名
	重命名表
	
	sQL分类:
DDL:数据定义语言,修改的结构 alter create drop truncate
DML :数据操纵语言,操作表中数据 insert update delete
DCL :数据控制语言, grant
DQL : select

	*/
原文地址:https://www.cnblogs.com/HelloBytes/p/14260676.html