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. Excel比较两列是否相等

    通常的方式: 先将两列排序 通过判定如 =A1=B1 或者ctrl + \ (mac 是 command) 可以定位到差异的那行

  2. join => innerJoin

    drupal7中 ->join == ->innerJoin 不是leftJoin哦 无语哦

  3. PyTables文件格式、PyTables 文件支持的数据类型

    翻译自 https://www.pytables.org/usersguide/file_format.html,http://www.pytables.org/usersguide/datatype ...

  4. 自定义jar包供ERP使用

    功能要求:需要在ERP中调用其他web服务或者自身web服务(比如跨账套过账等) 1.编写java程序,并将程序打包成jar包 import org.apache.http.HttpEntity; i ...

  5. 解决-装了WPS后Windows无法预览word、Excel、PPT等的问题

    https://www.bilibili.com/read/cv10469054/ https://www.cnblogs.com/qq3285862072/p/15097970.html Windo ...

  6. python manage.py loaddata dumpdata 用于导出和导入数据库中的数据

    1.数据导出python  manage.py  dumpdata python manage.py dumpdata [appname] > appname_data.json 指定appna ...

  7. unity task

    https://blog.csdn.net/weixin_43405845/article/details/105028291

  8. PostgreSQL 解析json字段

    一.解析json数组 select json_array_elements(lv_num_json)->'l1' lv,json_array_elements(lv_num_json)-> ...

  9. C#textbox更改字体颜色只读后不起作用的解决办法

    textbox的属性ReadOnly设置为true只读后,只更改字体颜色并不起作用. 解决办法是,连同背景色一起设置即可. textBox1.BackColor =textBox1.BackColor ...

  10. D2-Net: Weakly-Supervised Action Localization via Discriminative Embeddings and Denoised Activations概述

    1.针对的问题 目前大多数弱监督动作定位方法通常依赖于分离前景和背景区域(前-背景分离)学习TCAMs,但是在弱监督设置下,学习到的TCAM会存在噪声,而这些方法并没有明确地处理其噪声输出. 2.主要 ...