PLSQL 新建普通用户

1、使用system登录

2、File-->NEW-->SQL WINDOW

3、执行语句  

--创建用户
--create user 用户名 identified by 密码
create user scott identified by luckily
--给用户赋予权限
--赋予数据库登录链接权限
grant connect to scott;
--赋予资源操作权限
grant resource to scott;

Oracle忘记用户密码

1、cmd打开windows命令窗口

2、输入命令:sqlplus /nolog

3、输入命令:conn /as sysdba

4、输入命令:alter user 要修改的用户名 identified by 新的密码;

--单表查询
select *from emp
  --查询表中某个特定字段
  select empno from emp
  select empno,job from emp
  --给查询结果中的字段使用别名,as可省略
  select empno 员工编号,job as 工作, ename as "员工姓名" from emp
  --连接符: select 字段名||‘字符’||字段名 ... from 表名
  select empno||'的姓名是'||ename as "信息" from emp
  --去除重复:select distinct 字段名 from 表名
  --注意:去重是按行去重,多行数据相同取其一
  select distinct job from emp
  --排序:desc 降序 asc 升序
  select *from emp order by empno desc --单字段排序
  select *from emp order by empno,job asc --多字段排序
  --字段的逻辑运算
  select empno,ename,sal*2+1000 from emp
  select empno,ename,sal*2+1000,sal+comm from emp

  --条件限定(where)
    --各类运算符:=等于,>大于,<小于,>=大于或等于,<=小于或等于,<>不等于
    select *from emp where sal > 500
    --between and (查询900-2000的数据)
    select *from emp where sal between 900 and 2000
    --in (要么等于多少,要么等于多少)
    select *from emp where sal in(800,1600)
    --like(模糊查询,%表示任意匹配,有或者没有都可以,_表示有,并且只有一个)
    select *from emp where ename like '%a'
    --is null(查询为null的数据)
  select *from emp where job is null
  --逻辑运算符:AND与 OR或 NOT非
  select *from emp where sal<800 or sal>1500
--关联查询(需要两张表,left on)
--统计函数:count总数 max最大 min最小 avg平均
select count(*)from emp where sal>800 --统计工资高于800的人数
select max(sal),min(sal) from emp where deptno = 20 --统计deptno里为20的sal最大最小值
select avg(sal) from emp --sal的平均值
--分组函数group
select avg(sal),deptno from emp --统计deptno里的平均值
group by deptno
--having:对分组函数进行条件判断
select avg(sal),deptno from emp
group by deptno
having avg(sal)>2000 --统计大于2000的平均值
--子查询:子查询即可以简单的理解成同时执行多条sql语句将一条sql语句的查询结果作为条件来执行另一条sql语句
select count(*)from emp where sal>
(
select sal from emp where ename = 'SMITH'
)
--分页查询:rownum
select *from emp where rownum <= 5 --查询五条数据
select *from
(
select *from(select *from emp order by sal desc)
)
where rownum<=5 --查询薪水最高的五条记录

--Oracle创建新表
create table hero(
id number,
name varchar2(100),
hp number,
mp number,
speed number,
sex char(4),
birth date,
uskill varchar2(100)
)

--为新表添加数据
insert into hero values(001,'流浪法师',500,500,365,'男','08-4月-2005','曲径折跃');
insert into hero values(002,'战争之王',530,580,385,'男','18-9月-2008','大荒星陨');
insert into hero values(003,'弗拉基米尔',523,0,395,'男',to_date('2000-09-01','yyyy-mm-dd'),'鲜血潮汐');
insert into hero values(004,'拉克丝',500,600,309,'女','19-2月-2010','终极闪光');
insert into hero values(005,'虚空恐惧',600,570,378,'女','22-10月-2012','盛宴');
select *from hero
--修改数据
update hero set birth = to_date('2000-09-01','yyyy-mm-dd') where id = 3;
--删除数据
delete from hero where id = 5;
--舍去表:truncate table hero
--修改表结构:alter
--增加新的一列:alter table hero add (kills number)
--修改列:alter table hero modify(name varchar2(300))
--删除列:alter table hero drop column kills
--删除表:drop table 表名

约束种类 
唯一约束 unique 不可重复 
非空约束 not null 不能为空必须制定值 
主键约束 primary key 通常是给id使用的,同时具备了unique和not null约束 
外键约束 foreign key

Oracle_20200416的更多相关文章

随机推荐

  1. ESP32-IDF 在vscode环境搭建

    前言 由于许多的未知原因,我尝试过许多网上教程,在vscode上搭建ESP-IDF环境,但结果是耗费了大把时间,结果还非常不理想. 在参考了(一)esp32开发环境搭建(VSCode+IDF实现单步调 ...

  2. C++并发编程实战(第2版)

    这本书翻译的烂,写的也不好. 甚至不如看cppreference. 这本书英文叫C++ Concurrency in Action, Second Edition 英文原版也是垃圾,C++实在没有写得 ...

  3. SQL Server【提高】分区表

    分区表 分区视图 分区表可以从物理上将一个大表分成几个小表,但是从逻辑上来看,还是一个大表. 什么时候需要分区表 数据库中某个表中的数据很多. 数据是分段的 分区的方式 水平分区 水平表分区就是将一个 ...

  4. wamp+phpstrom+Xdebuge helper(google)

    一.软件安装两个软件的安装和第三个浏览器插件就不再赘述,网上有很多详细的教程,自行百度. 二.配置步骤1.wampwamp的优势在于自带xdebuge的dll文件,所以不需要在官网根据版本下载,具体位 ...

  5. 解决 http://www.diamond-sh.com/favicon.ico 404 (Not Found) 报错问题

    html5页面中经常会遇到这个报错,解决方法有以下两种: 1. 根目录下建一个个favicon.ico文件,在head标签引入favicon.ico文件即可 <link href="f ...

  6. vl_nnconv.mexw64找不到指定模块

    在Installing and compiling the library--matconvnet-1.0-beta25时遇到的错误,总是提示"Invalid MEX-file 'C:\Us ...

  7. SVN安装配置手册

    1.官网下载相关的服务端的安装包 SVN(版本控制器): SVN-客户端:TortoiseSVN SVN-服务端:VisualSVN 下载地址: TortoiseSVN:https://tortois ...

  8. ComPiler200002:Growing a Compiler

    http://www.cs.dartmouth.edu/~mckeeman/cs48/mxcom/gem/html/GrowingCompiler.html by Bill McKeeman and ...

  9. 跨时钟域之异步FIFO

    参考:https://www.cnblogs.com/aslmer/p/6114216.html 文章:Simulation and Synthesis Techniques for Asynchro ...

  10. requests断点续传功能

    requests取消ssl验证会出现告警InsecureRequestWarning,取消告警如下: import urllib3urllib3.disable_warnings(urllib3.ex ...