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. js中的this的指向问题

    this的指向在函数定义的时候是确定不了的,只有函数执行的时候才能确定this到底指向谁,实际上this的最终指向的是那个调用它的对象 this永远指向的是最后调用它的对象,也就是看它执行的时候是谁调 ...

  2. profile2的原理猜想

    1, profile2 是一个 entity_type,  可以包含fields, 每个用户都对应一个profile的id, 其实就是type id, 就相当于bundle, 所谓的函数profile ...

  3. Characterizing possible failure modes in physics-informed neural network

    NeurIPS 2021 表征PINN中可能的失败模式.本文的思路也比较简单,通过对PINN的优化域进行观察,发现导致PINN训练的原因并不是因为神经网络的表达力不足,而是由于PINN中引入了基于PD ...

  4. centos7普通用户拥有root权限并登录执行脚本

    1.useradd test 2.passwd test 3.usermod -s 脚本绝对路径 test 4.vi /etc/passwd修改test用户的uid和gid为0

  5. FastReport 单元行自动换行 Table Object AutoSize

    FastReport 官方实例138.fr3 有关于单元行自动换行的描述.The table object can grow depends on cells content. Notes:- set ...

  6. AD笔记总结

    原理图要点: 1.新建工程, 新建的project是要以后缀PrjPCB2.新建原理图.PCB, 右键project,进行New添加3.新建原理图库.PCB库,右键project, 进行new添加 改 ...

  7. Java 多线程 术语

    并行和并发:并发偏重于多个任务交替执行.并行是真正意义上的"同时执行".但两者的最终效果是一样的: 同步和异步:同步是指在同一时间里,一个同步方法调用后需要返回后,才能继续后续的行 ...

  8. 阿里开源的几个中间件 dubbo/RocketMQ/canal/druid 代码还是很不错的

    阿里开源的几个中间件 dubbo/RocketMQ/canal/druid 代码还是很不错的

  9. 配置windows server多个用户同时使用一个账户远程服务器

    首先,需要服务器开启远程桌面连接: 右键点击"这台电脑"弹出菜单栏,选择"属性"   弹出系统窗口,点击"远程设置"   弹出系统属性窗口, ...

  10. maven install 报错 The POM for com.oracle:ojdbc6:jar:11.2.0.7.0 is missing, no dependency information available

    The POM for com.oracle:ojdbc6:jar:11.1.0.7.0 is missing, no dependency information available The POM ...