当前位置: 首页 > news >正文

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页面传参

一&#xff0c;用query传参 方法&#xff1a; router.push({path: ‘路由地址’, query: ‘参数’}) 例子&#xff1a;a页面携带参数跳转到b页面并且b页面拿到a页面传递过来的参数 在路由router.ts配置 a页面&#xff1a; <template><div >a页面</div>…...

QNX OS微内核系统

微内核架构 微内核(Microkernel)架构是一种操作系统架构模式,其核心思想是尽量将操作系统的基本功能压缩在最小的核心中,而将其他服务(如设备驱动、文件系统、网络协议等)放在用户空间中运行,从而增加系统的灵活性和安全性,这种架构有几个主要特点和优势: 最小化核心…...

ViT:5 Knowledge Distillation

实时了解业内动态&#xff0c;论文是最好的桥梁&#xff0c;专栏精选论文重点解读热点论文&#xff0c;围绕着行业实践和工程量产。若在某个环节出现卡点&#xff0c;可以回到大模型必备腔调或者LLM背后的基础模型重新阅读。而最新科技&#xff08;Mamba,xLSTM,KAN&#xff09;…...

2024头歌数据库期末综合(部分题)

目录 第7关&#xff1a;数据查询三 任务描述 知识补充 答案 第8关&#xff1a;数据查询四 任务描述 知识补充 答案 本篇博客声明&#xff1a;所有题的答案不在一起&#xff0c;可以去作者博客专栏寻找其它文章。 第7关&#xff1a;数据查询三 任务描述 本关任务&#x…...

【Flask】学习

参考B站视频&#xff1a;https://www.bilibili.com/video/BV1v7411M7us/ 目录 第一讲 什么是 flask 修饰器、路由规则 flask 变量规则&#xff0c;灵活传参数据类型&#xff1a;str、int、float&#xff08;正浮点数&#xff0c;传int会报错&#xff09;、path、uuid app.…...

图像数字化基础

一、像素 1、获取图像指定位置的像素 import cv2 image cv2.imread("E:\\images\\2.png") px image[291,218] print("坐标(291,218)上的像素的BGR值是&#xff1a;",px) &#xff08;1&#xff09;RGB色彩空间 R通道&#xff1a;红色通道 G通道&…...

让你的Python代码更简洁:一篇文章带你了解Python列表推导式

文章目录 📖 介绍 📖🏡 演示环境 🏡📒 列表推导式 📒📝 语法📝 条件筛选📝 多重循环📝 列表推导式的优点📝 使用场景📝 示例代码🎯 示例1🎯 示例2⚓️ 相关链接 ⚓️📖 介绍 📖 在Python编程中,列表推导式是一种强大且高效的语法,它允许你用…...

基于Matlab的BP神经网络的车牌识别系统(含GUI界面)【W7】

简介&#xff1a; 本系统结合了图像处理技术和机器学习方法&#xff08;BP神经网络&#xff09;&#xff0c;能够有效地实现车牌的自动识别。通过预处理、精确定位、字符分割和神经网络识别&#xff0c;系统能够准确地识别各种车牌图像&#xff0c;并在智能交通管理、安防监控等…...

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接口:获取商品详情

核心功能介绍——获取商品详情 在竞争激烈的电商市场中&#xff0c;快速、准确地获取商品数据详情对于电商业务的成功至关重要。此Temu接口的核心功能在于其能够实时、全面地获取平台上的商品数据详情。商家通过接入Temu接口&#xff0c;可以轻松获取商品的标题、价格、库存、…...

ArcGIS Pro SDK (五)内容 2 工程项

ArcGIS Pro SDK &#xff08;五&#xff09;内容 2 地图工程 目录 ArcGIS Pro SDK &#xff08;五&#xff09;内容 2 地图工程1 将文件夹连接项添加到当前工程2.2 获取所有工程项2.3 获取工程的所有“MapProjectItems”2.4 获取特定的“MapProjectItem”2.5 获取所有“样式工程…...

【ai】初识pytorch

初识PyTorch 大神的例子运行: 【ai】openai-quickstart 配置pycharm工程 简单例子初识一下Pytorch 好像直接点击下载比较慢? 大神的代码 在这个例子中,首先定义一个线性模型,该模型有一个输入特征和一个输出特征。然后定义一个损失函数和一个优化器,接着生成一些简单的线性…...

pcl::PointXYZRGBA造成点云无法显示

如果pcd文件没有rgba信息&#xff0c;使用pcl::PointXYZRGBA类型打开会提示以下信息&#xff1a; Failed to find match for field rgba另外&#xff0c;显示出来的点云是黑色&#xff0c;如果使用默认背景色为黑色&#xff0c;就无法显示点云了。 如果设置其它背景色&#xf…...

【论文精读】分类扩散模型:重振密度比估计(Revitalizing Density Ratio Estimation)

文章目录 一、文章概览&#xff08;一&#xff09;问题的提出&#xff08;二&#xff09;文章工作 二、理论背景&#xff08;一&#xff09;密度比估计DRE&#xff08;二&#xff09;去噪扩散模型 三、方法&#xff08;一&#xff09;推导分类和去噪之间的关系&#xff08;二&a…...

kubesphere踩过的坑,持续更新....

踩过的坑 The connection to the server lb.kubesphere.local:6443 was refused - did you specify the right host… 另一篇文档中 dashboard 安装 需要在浏览器中输入thisisunsafe,即可进入登录页面 ingress 安装的问题 问题描述&#xff1a; 安装后通过命令 kubectl g…...

【Python内存管理黄金法则】:20年SRE亲授生产环境OOM崩溃前的5个关键干预点

第一章&#xff1a;Python智能体内存管理策略的底层认知与生产意义Python智能体&#xff08;如基于LLM的Agent系统&#xff09;在长时间运行、多轮对话与状态缓存场景下&#xff0c;内存行为远超传统脚本应用。其内存压力不仅来自模型权重加载&#xff0c;更源于动态生成的中间…...

SVN分支管理避坑指南:为什么你的Merge two different trees总会删文件?

SVN分支合并的底层逻辑与实战避坑指南 当你面对SVN分支合并时是否经常遇到文件神秘消失的情况&#xff1f;特别是使用TortoiseSVN的"Merge two different trees"功能时&#xff0c;那些本应保留的文件为何总是不翼而飞&#xff1f;本文将深入解析SVN合并的底层机制&a…...

解锁浏览器潜能:用户脚本实用指南

解锁浏览器潜能&#xff1a;用户脚本实用指南 【免费下载链接】greasyfork An online repository of user scripts. 项目地址: https://gitcode.com/gh_mirrors/gr/greasyfork 你是否常常觉得浏览器功能不够用&#xff1f;想让网页自动完成重复操作&#xff1f;希望个性…...

YOLOv8模型在RKNN平台上的实战部署指南(附完整代码)

YOLOv8模型在RKNN平台上的实战部署指南&#xff08;附完整代码&#xff09; 在嵌入式设备上部署高性能目标检测模型一直是计算机视觉领域的难点。瑞芯微&#xff08;Rockchip&#xff09;推出的RKNN推理框架为这一挑战提供了解决方案&#xff0c;尤其适合需要低功耗、高效率的边…...

使用ZLMRTCClient.j实现webRtc流播放

1. 核心播放器组件封装 (WebRTCPlayer.vue)为了在项目中复用播放逻辑&#xff0c;我们首先封装一个 WebRTCPlayer 组件。该组件主要负责&#xff1a;初始化播放器实例&#xff1a;配置 ZLMRTCClient.Endpoint。处理自动播放&#xff1a;解决浏览器禁止带音频自动播放的问题。生…...

用ESP32和TB6612FNG做个遥控小车:从硬件接线到Arduino代码调试全记录

从零打造ESP32智能遥控小车&#xff1a;硬件选型、代码优化与避坑指南 项目背景与核心组件解析 去年夏天&#xff0c;我在工作室里堆满了各种电机和开发板&#xff0c;试图为侄子制作一个生日礼物——能通过手机控制的遥控小车。经过多次迭代&#xff0c;最终选择了ESP32TB6612…...

知乎上线求职工具,助力毕业生破困局

知乎上线求职利器&#xff0c;直击毕业生痛点2026届全国普通高校毕业生预计达1270万人&#xff0c;再创历史新高。与此同时&#xff0c;AI技术加速行业重构&#xff0c;部分传统岗位需求收缩&#xff0c;大量毕业生陷入“海投”困境&#xff0c;难以精准定位自身。在此背景下&a…...

MongoDB:如何构建“数据回收站“,防止人为误删数据(延迟节点)

更多内容请见: 《深入掌握MongoDB数据库》 - 专栏介绍和目录 一、引言:数据误删的现实挑战 在企业级数据库系统中,人为误删数据是导致业务中断的常见原因。根据2023年数据库安全报告,37%的数据丢失事件是由人为错误引起的,其中误删除操作占主要部分。MongoDB作为企业级No…...

从特效 SDK 到 AI 动效平台:Neon Vibe Motion 的技术演进之路

多媒体中台在 B 站主要负责剪辑、拍摄、直播等业务场景的动效渲染&#xff0c;开发维护的 SDK 在后文统一称为特效 SDK。 传统的视频特效生产一般分三条链路&#xff1a; 三条链路存在一个困境&#xff1a;效果丰富度、实时可交互、生产效率&#xff0c;三者不可兼得。 那么能…...

Qwerty Learner单词难度分级:智能调整训练强度的终极指南

Qwerty Learner单词难度分级&#xff1a;智能调整训练强度的终极指南 【免费下载链接】qwerty-learner 为键盘工作者设计的单词记忆与英语肌肉记忆锻炼软件 / Words learning and English muscle memory training software designed for keyboard workers 项目地址: https://…...