Oracle day9
------------------------------------------------------------------------------------
--创建用户
create user test1 identified by 123456;
create user ZJun identified by 888888;
--授予权限
grant create session to test1;
grant create session to ZJun;
--删除用户
drop user test1;
drop user ZJun;
--修改用户
alter user test1 identified by 654321;
alter user ZJun identified by 666666;
alter user test1 identified by 123456;
------------------------------------------------------------------------------------
/*CREATE TABLE G1212(
X INT,
L VARCHAR2(10)) ;
INSERT INTO G1212 VALUES(1, 'A');
INSERT INTO G1212 VALUES(2, 'A');
INSERT INTO G1212 VALUES(3, 'A');
INSERT INTO G1212 VALUES(4, 'A');
INSERT INTO G1212 VALUES(5, 'B');
INSERT INTO G1212 VALUES(6, 'B');
INSERT INTO G1212 VALUES(7, 'B');
INSERT INTO G1212 VALUES(8, 'A');
INSERT INTO G1212 VALUES(9, 'A');*/
select t.l,min(t.x)||'-'||max(t.x) r from
(select l,X,(X-row_number()over(partition by l order by x)) r from G1212) t
group by t.l,t.r order by t.l ;
------------------------------------------------------------------------------------
--系统权限
--查看当前用户系统权限列表
select * from user_sys_privs;
--授权系统权限
grant create session to test1;
--传递系统权限
grant create view to ZJun with admin option;
--连接ZJun执行下面
grant create view to test1;
--回收系统权限
revoke create view from test1;
--对象权限
--授权对象权限
grant all on scott.emp to test1;
--连接到test1执行查询语句
select * from scott.emp;
--传递对象权限
grant all on scott.dept to ZJun with grant option;
--连接到ZJun
select * from scott.dept;
grant all on scott.dept to test1;
--连接到test1
select * from scott.dept;
--回收对象权限
revoke all on scott.dept from ZJun;
revoke all on scott.emp from test1;
--角色:一系列相关权限的集合
--查看当前登录用户所拥有的角色
select * from role_sys_privs;
-- connect: create sesion
grant create session to test1; --授予权限
grant connect to test1; --授予角色
--DBA:包含所有系统权限
grant DBA to ZJun;
--resourse:一系列开发权限
grant RESOURCE to ZJun;
--自定义角色
create role role1;
grant create session,create table,create view to role1;
grant role1 to ZJun;
--回收角色
revoke DBA,RESOURCE from ZJun;
--删除角色:drop role 角色名
drop role role1;
------------------------------------------------------------------------------------
--创建表
/*create table cartoon(
name char(50) default '西游记',
role char(50) default '孙悟空',
role_age number(3) default 500
);*/
select * from cartoon;
/*insert into cartoon values('喜羊羊与灰太狼','懒羊羊',12);
insert into cartoon values('大耳朵图图','胡图图',6);
insert into cartoon values('大头儿子和小头爸爸','大头儿子',3);
insert into cartoon(name,role) values('西游记','孙悟空');*/
comment on table cartoon is '动画片';
comment on column cartoon.name is '名字';
comment on column cartoon.role is '主角';
comment on column cartoon.role_age is '主角年龄';
comment on table emp is '员工信息表';
comment on column emp.ename is '姓名';
comment on column emp.empno is '编号';
comment on column emp.job is '职位';
comment on column emp.hiredate is '入职日期';
comment on column emp.sal is '薪资';
comment on column emp.comm is '奖金';
comment on column emp.deptno is '所属部门';
comment on column emp.mgr is '上级编号';
comment on table dept is '部门表';
comment on column dept.dname is '部门名称';
comment on column dept.deptno is '部门编号';
comment on column dept.loc is '所在地区';
create table c_bak as select * from cartoon;
select * from c_bak;
------------------------------------------------------------------------------------
drop table reader;
create table book(
no number primary key,
title char(500),
author char(50),
publish char(500),
pub_date date,
price number
);
select * from book;
/*insert into book
values(100001,'Oracle 9i 数据库系统管理','李代平',
'冶金工业出版社',to_date('2003-01-01','yyyy-MM-dd'),38);
insert into book
values(100002,'Oracle 9i 中文版入门与提高','赵松涛',
'人民邮电出版社',to_date('2002-07-01','yyyy-MM-dd'),35);
insert into book
values(100003,'Oracle 9i 开发指南:PL/SQL 程序设计','Joan Casteel',
'电子工业出版社',to_date('2004-04-03','yyyy-MM-dd'),49);
insert into book
values(100004,'数据库原理辅助与提高','盛定宇',
'电子工业出版社',to_date('2004-03-01','yyyy-MM-dd'),34);
insert into book
values(100005,'Oracle 9i 中文版实用培训教程','赵伯山',
'电子工业出版社',to_date('2002-01-01','yyyy-MM-dd'),21);
insert into book
values(100006,'Oracle 8 实用教程','翁正科等',
'电子工业出版社',to_date('2003-07-08','yyyy-MM-dd'),38);*/
create table reader(
rno number primary key,
rname char(50)
);
select * from reader;
/*insert into reader values(200001,'张三');
insert into reader values(200002,'李凤');
insert into reader values(200003,'孟欣');
insert into reader values(200004,'谢非');
insert into reader values(200005,'刘英');*/
drop table borrow;
create table borrow(
no number references book(no),
rno number references reader(rno),
borrow_date date
);
select * from borrow;
/*insert into borrow values(100001,200001,
to_date('2004-04-08 10:06:14','yyyy-MM-dd hh24:mi:ss'));
insert into borrow values(100002,200002,
to_date('2004-04-08 10:06:27','yyyy-MM-dd hh24:mi:ss'));
insert into borrow values(100003,200003,
to_date('2004-04-08 10:06:36','yyyy-MM-dd hh24:mi:ss'));
insert into borrow values(100004,200004,
to_date('2004-04-08 10:06:48','yyyy-MM-dd hh24:mi:ss'));
insert into borrow values(100005,200005,
to_date('2004-04-08 10:06:58','yyyy-MM-dd hh24:mi:ss'));*/
select * from book,reader,borrow where book.no = borrow.no
and reader.rno = borrow.rno;
------------------------------------------------------------------------------------
drop table "Employee";
create table "Employee"(
"EmplID" varchar(4) primary key not null,
"EmplName" varchar(12) not null,
"Sex" varchar(3) not null,
"Birthday" date not null,
"Address" varchar(30),
"Wages" number not null,
"DeptID" varchar(4) references "Department"("DeptID")
);
select * from "Employee";
comment on table "Employee" is 'Employee表';
comment on column "Employee"."EmplID" is '员工号';
comment on column "Employee"."EmplName" is '姓名';
comment on column "Employee"."Sex" is '性别';
comment on column "Employee"."Birthday" is '出生日期';
comment on column "Employee"."Address" is '地址';
comment on column "Employee"."Wages" is '工资';
comment on column "Employee"."DeptID" is '部门号';
------------------------------------------------------------------------------------
drop table "Department";
create table "Department"(
"DeptID" varchar(4) primary key not null,
"DeptName" varchar(30) not null
);
select * from "Department";
comment on table "Department" is 'Department表';
comment on column "Department"."DeptID" is '部门号';
comment on column "Department"."DeptName" is '部门名称';
------------------------------------------------------------------------------------
CREATE TABLE F801(
日期 DATE,
类型 VARCHAR2(10),
金额 number
);
/*INSERT INTO F801 VALUES (to_date('2021-01-01','yyyy_mm_dd'),'借款',100);
INSERT INTO F801 VALUES (to_date('2021-01-31','yyyy_mm_dd'),'借款',-50);
INSERT INTO F801 VALUES (to_date('2021-01-20','yyyy_mm_dd'),'还款',50);
INSERT INTO F801 VALUES (to_date('2021-01-23','yyyy_mm_dd'),'还款',-20);
INSERT INTO F801 VALUES (to_date('2021-02-01','yyyy_mm_dd'),'借款',100);
INSERT INTO F801 VALUES (to_date('2021-02-28','yyyy_mm_dd'),'借款',-50);
INSERT INTO F801 VALUES (to_date('2021-02-20','yyyy_mm_dd'),'还款',50);
INSERT INTO F801 VALUES (to_date('2021-02-23','yyyy_mm_dd'),'还款',-20);
INSERT INTO F801 VALUES (to_date('2021-03-01','yyyy_mm_dd'),'借款',100);
INSERT INTO F801 VALUES (to_date('2021-03-31','yyyy_mm_dd'),'借款',-50);
INSERT INTO F801 VALUES (to_date('2021-03-20','yyyy_mm_dd'),'还款',50);
INSERT INTO F801 VALUES (to_date('2021-03-23','yyyy_mm_dd'),'还款',-20);*/
select * from F801;
---错解
/*
with tt as (select * from (select t.月份,t.类型,sum(t.金额) from(
select to_char(f.日期,'yyyy')||'-'||to_char(f.日期,'MM') as 月份,f.类型,f.金额,
sum(金额)over(partition by extract(month from 日期),f.类型 order by 金额 )
from F801 f )t group by t.月份,t.类型 order by t.月份))
select tt.月份,max(decode(tt.类型,借款,tt.借款金额,0)) from
(select * from (select t.月份,t.类型,sum(t.金额) from(
select to_char(f.日期,'yyyy')||'-'||to_char(f.日期,'MM') as 月份,f.类型,f.金额,
sum(金额)over(partition by extract(month from 日期),f.类型 order by 金额 )
from F801 f )t group by t.月份,t.类型 order by t.月份)) tt;
select* from f801;
*/
select t.月份,t.借款 as 借款金额, t.还款 as 还款金额,sum(t.借款)over(order by t.月份) as 累计借款,
sum(t.还款)over(order by t.月份) as 累计还款 from(
select to_char(f.日期,'yyyy-MM') as 月份,
sum(decode(f.类型,'借款',f.金额,0)) 借款,sum(decode(f.类型,'还款',f.金额,0)) 还款
from F801 f group by to_char(f.日期,'yyyy-MM')) t group by t.月份,t.借款,t.还款;
select t.月份,t.借款 as 借款金额,t.还款 as 还款金额,sum(t.借款)over(order by t.月份) as 累计借款,
sum(t.还款)over(order by t.月份) as 累计还款
from (select to_char(日期,'yyyy-MM') as 月份,sum(借款) as 借款,sum(还款) as 还款 from f801
pivot(sum(金额) for 类型 in ('借款' as 借款,'还款' as 还款))group by to_char(日期,'yyyy-MM') ) t;
相关文章:
Oracle day9
------------------------------------------------------------------------------------ --创建用户 create user test1 identified by 123456; create user ZJun identified by 888888; --授予权限 grant create session to test1; grant create session to ZJun; --删除用…...
Race Condition竞争条件
Race Condition Question – why was there no race condition in the first solution (where at most N – 1) buffers can be filled?Processes P0 and P1 are creating child processes using the fork() system callRace condition on kernel variable next_available_pid…...
docker 删除本地镜像释放磁盘空间
时间一长,本地镜像文件特别多: 1 linux 配置crontab 定期删除 crontab l 查看 crontab e 编辑 30 3 * * * /home/mqq/gengmingming/cleanImage-realize.sh > /home/mqq/gengmingming/cleanImage-realize.log 2>&12 cleanImage-realize.sh …...
JVM中的垃圾回收器
文章目录 垃圾回收器发展史垃圾回收器分类按线程数分类按工作模式分类按处理方式分类 查看默认垃圾收集器评估垃圾回收器性能指标吞吐量暂停时间吞吐量对比暂停时间 7种经典的垃圾回收器垃圾回收器与垃圾分代垃圾收集器的组合关系Serial GCParNew GCParallel Scavenge GCSerial…...
记录一些可用的AI工具网站
记录一些可用的AI工具网站 AI对话大模型AI图片生成AI乐曲生成AI视频生成AI音频分离 AI对话大模型 当前时代巅峰,Microsoft Copilot:https://copilot.microsoft.com AI图片生成 stable diffusion模型资源分享社区,civitai:https…...
vue3页面传参
一,用query传参 方法: router.push({path: ‘路由地址’, query: ‘参数’}) 例子:a页面携带参数跳转到b页面并且b页面拿到a页面传递过来的参数 在路由router.ts配置 a页面: <template><div >a页面</div>…...
QNX OS微内核系统
微内核架构 微内核(Microkernel)架构是一种操作系统架构模式,其核心思想是尽量将操作系统的基本功能压缩在最小的核心中,而将其他服务(如设备驱动、文件系统、网络协议等)放在用户空间中运行,从而增加系统的灵活性和安全性,这种架构有几个主要特点和优势: 最小化核心…...
ViT:5 Knowledge Distillation
实时了解业内动态,论文是最好的桥梁,专栏精选论文重点解读热点论文,围绕着行业实践和工程量产。若在某个环节出现卡点,可以回到大模型必备腔调或者LLM背后的基础模型重新阅读。而最新科技(Mamba,xLSTM,KAN)…...
2024头歌数据库期末综合(部分题)
目录 第7关:数据查询三 任务描述 知识补充 答案 第8关:数据查询四 任务描述 知识补充 答案 本篇博客声明:所有题的答案不在一起,可以去作者博客专栏寻找其它文章。 第7关:数据查询三 任务描述 本关任务&#x…...
【Flask】学习
参考B站视频:https://www.bilibili.com/video/BV1v7411M7us/ 目录 第一讲 什么是 flask 修饰器、路由规则 flask 变量规则,灵活传参数据类型:str、int、float(正浮点数,传int会报错)、path、uuid app.…...
图像数字化基础
一、像素 1、获取图像指定位置的像素 import cv2 image cv2.imread("E:\\images\\2.png") px image[291,218] print("坐标(291,218)上的像素的BGR值是:",px) (1)RGB色彩空间 R通道:红色通道 G通道&…...
让你的Python代码更简洁:一篇文章带你了解Python列表推导式
文章目录 📖 介绍 📖🏡 演示环境 🏡📒 列表推导式 📒📝 语法📝 条件筛选📝 多重循环📝 列表推导式的优点📝 使用场景📝 示例代码🎯 示例1🎯 示例2⚓️ 相关链接 ⚓️📖 介绍 📖 在Python编程中,列表推导式是一种强大且高效的语法,它允许你用…...
基于Matlab的BP神经网络的车牌识别系统(含GUI界面)【W7】
简介: 本系统结合了图像处理技术和机器学习方法(BP神经网络),能够有效地实现车牌的自动识别。通过预处理、精确定位、字符分割和神经网络识别,系统能够准确地识别各种车牌图像,并在智能交通管理、安防监控等…...
jetpack compose的@Preview和自定义主题
1.Preview Preview可以在 Android Studio 的预览窗口中实时查看和调试 UI 组件。 基本使用 import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.material.MaterialTheme import androidx.compose.material.Surface import androidx.compose.ma…...
Temu(拼多多跨境电商) API接口:获取商品详情
核心功能介绍——获取商品详情 在竞争激烈的电商市场中,快速、准确地获取商品数据详情对于电商业务的成功至关重要。此Temu接口的核心功能在于其能够实时、全面地获取平台上的商品数据详情。商家通过接入Temu接口,可以轻松获取商品的标题、价格、库存、…...
ArcGIS Pro SDK (五)内容 2 工程项
ArcGIS Pro SDK (五)内容 2 地图工程 目录 ArcGIS Pro SDK (五)内容 2 地图工程1 将文件夹连接项添加到当前工程2.2 获取所有工程项2.3 获取工程的所有“MapProjectItems”2.4 获取特定的“MapProjectItem”2.5 获取所有“样式工程…...
【ai】初识pytorch
初识PyTorch 大神的例子运行: 【ai】openai-quickstart 配置pycharm工程 简单例子初识一下Pytorch 好像直接点击下载比较慢? 大神的代码 在这个例子中,首先定义一个线性模型,该模型有一个输入特征和一个输出特征。然后定义一个损失函数和一个优化器,接着生成一些简单的线性…...
pcl::PointXYZRGBA造成点云无法显示
如果pcd文件没有rgba信息,使用pcl::PointXYZRGBA类型打开会提示以下信息: Failed to find match for field rgba另外,显示出来的点云是黑色,如果使用默认背景色为黑色,就无法显示点云了。 如果设置其它背景色…...
【论文精读】分类扩散模型:重振密度比估计(Revitalizing Density Ratio Estimation)
文章目录 一、文章概览(一)问题的提出(二)文章工作 二、理论背景(一)密度比估计DRE(二)去噪扩散模型 三、方法(一)推导分类和去噪之间的关系(二&a…...
kubesphere踩过的坑,持续更新....
踩过的坑 The connection to the server lb.kubesphere.local:6443 was refused - did you specify the right host… 另一篇文档中 dashboard 安装 需要在浏览器中输入thisisunsafe,即可进入登录页面 ingress 安装的问题 问题描述: 安装后通过命令 kubectl g…...
观成科技:隐蔽隧道工具Ligolo-ng加密流量分析
1.工具介绍 Ligolo-ng是一款由go编写的高效隧道工具,该工具基于TUN接口实现其功能,利用反向TCP/TLS连接建立一条隐蔽的通信信道,支持使用Let’s Encrypt自动生成证书。Ligolo-ng的通信隐蔽性体现在其支持多种连接方式,适应复杂网…...
[2025CVPR]DeepVideo-R1:基于难度感知回归GRPO的视频强化微调框架详解
突破视频大语言模型推理瓶颈,在多个视频基准上实现SOTA性能 一、核心问题与创新亮点 1.1 GRPO在视频任务中的两大挑战 安全措施依赖问题 GRPO使用min和clip函数限制策略更新幅度,导致: 梯度抑制:当新旧策略差异过大时梯度消失收敛困难:策略无法充分优化# 传统GRPO的梯…...
Spark 之 入门讲解详细版(1)
1、简介 1.1 Spark简介 Spark是加州大学伯克利分校AMP实验室(Algorithms, Machines, and People Lab)开发通用内存并行计算框架。Spark在2013年6月进入Apache成为孵化项目,8个月后成为Apache顶级项目,速度之快足见过人之处&…...
vue3 定时器-定义全局方法 vue+ts
1.创建ts文件 路径:src/utils/timer.ts 完整代码: import { onUnmounted } from vuetype TimerCallback (...args: any[]) > voidexport function useGlobalTimer() {const timers: Map<number, NodeJS.Timeout> new Map()// 创建定时器con…...
腾讯云V3签名
想要接入腾讯云的Api,必然先按其文档计算出所要求的签名。 之前也调用过腾讯云的接口,但总是卡在签名这一步,最后放弃选择SDK,这次终于自己代码实现。 可能腾讯云翻新了接口文档,现在阅读起来,清晰了很多&…...
快刀集(1): 一刀斩断视频片头广告
一刀流:用一个简单脚本,秒杀视频片头广告,还你清爽观影体验。 1. 引子 作为一个爱生活、爱学习、爱收藏高清资源的老码农,平时写代码之余看看电影、补补片,是再正常不过的事。 电影嘛,要沉浸,…...
DBLP数据库是什么?
DBLP(Digital Bibliography & Library Project)Computer Science Bibliography是全球著名的计算机科学出版物的开放书目数据库。DBLP所收录的期刊和会议论文质量较高,数据库文献更新速度很快,很好地反映了国际计算机科学学术研…...
使用python进行图像处理—图像滤波(5)
图像滤波是图像处理中最基本和最重要的操作之一。它的目的是在空间域上修改图像的像素值,以达到平滑(去噪)、锐化、边缘检测等效果。滤波通常通过卷积操作实现。 5.1卷积(Convolution)原理 卷积是滤波的核心。它是一种数学运算,…...
LTR-381RGB-01RGB+环境光检测应用场景及客户类型主要有哪些?
RGB环境光检测 功能,在应用场景及客户类型: 1. 可应用的儿童玩具类型 (1) 智能互动玩具 功能:通过检测环境光或物体颜色触发互动(如颜色识别积木、光感音乐盒)。 客户参考: LEGO(乐高&#x…...
【Java基础】向上转型(Upcasting)和向下转型(Downcasting)
在面向对象编程中,转型(Casting) 是指改变对象的引用类型,主要涉及 继承关系 和 多态。 向上转型(Upcasting) ⬆️ 定义 将 子类对象 赋值给 父类引用(自动完成,无需强制转换&…...
