Oracle

Oracle SQL : how to find just record from a group

梦想与她 提交于 2021-02-11 13:12:28
问题 I have a table where there is a PrimaryKey, Foreign Key. I just want to find the list of one Primary per Foreign Key. Example I need a query that returns only Primary Keys (1 or 2 or 3) and (4 or 5) or (6 or 7 or 8) Essentially 1,4 and 6. How can I get just one PK for each Foreign key 回答1: Use aggregation: select foreignKey, min(primaryKey) from t group by foreignKey; If you want a random value, you can use the keep syntax: select foreignKey, min(primaryKey) keep (dense_rank first order by

Oracle锁表与解锁 对象锁与解锁

谁说胖子不能爱 提交于 2021-02-11 13:08:19
阅读目录 锁表与解锁 查看锁表进程SQL语句 解锁 对象锁与解锁 回到顶部 锁表与解锁 查看锁表进程SQL语句 select * from v$session t1, v$locked_object t2 where t1.sid = t2.SESSION_ID; 解锁 杀掉锁表进程: 记录下SID和serial# ,分别替换掉下面的1155,39095,即可解除锁表 alter system kill session ' 1155,39095 ' ; 回到顶部 对象锁与解锁 这里以包为PKG_ZLGL_BASEDATA为例 注意name为包或者存储过程等; SELECT * FROM V$DB_OBJECT_CACHE WHERE name = ' PKG_ZLGL_BASEDATA ' AND LOCKS != ' 0 ' ; 查看sid 注意object为包或者存储过程等; SELECT SID from V$ACCESS WHERE object = ' PKG_ZLGL_BASEDATA ' ; 查看查看SID和SERIAL# in后面的条件为上述查的sid SELECT SID,SERIAL#,PADDR,STATUS FROM V$SESSION WHERE SID IN ( ' 283 ' , ' 343 ' ); 杀进程 实例如下: alter system

docker+mysql基本搭建过程,及修改时间

我们两清 提交于 2021-02-11 13:08:01
修改系统时间 [root@32c64- 0425445 ~]# ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/ localtime 或者 [root@32c64 - 0425445 ~]# cp /usr/share/zoneinfo/Asia/Shanghai /etc/ localtime 或者 [root@32c64 - 0425445 ~ ]# systemctl enable ntpd [root@32c64 - 0425445 ~]# systemctl start ntpd 查询镜像 [root@bms-e4e3 ~ ]# docker search mysql INDEX NAME DESCRIPTION STARS OFFICIAL AUTOMATED docker.io docker.io /mysql MySQL is a widely used, open-source relati... 7708 [OK] docker.io docker.io /mariadb MariaDB is a community-developed fork of M... 2530 [OK] docker.io docker.io /mysql/mysql-server Optimized MySQL Server Docker

分享5个免费的在线 SQL 数据库环境,简直太方便了!

时光毁灭记忆、已成空白 提交于 2021-02-11 13:06:02
点击上方蓝色“ 程序猿DD ”,选择“设为星标” 回复“ 资源 ”获取独家整理的学习资料! 作者 | 不剪发的Tony老师 来源 | blog.csdn.net/horses/article/details/108603935 大今天给大家分享几个在线的免费 SQL 运行环境,也就是在线数据库。这些网站可以帮助我们快速运行一些 SQL 语句的测试或者验证,同时还可以在网络上进行分享,关键不需要自己安装数据库。 SQL Fiddle SQL Fiddle 提供了 MySQL、Oracle、PostgreSQL、SQLite 以及 SQL Server 数据库环境,使用时无需注册。 SQL Fiddle 其中,左侧文本框用于输入初始化语句创建表结构和数据,点击“Build Schema📥”运行;也可以通过“Text to DDL”将格式化文本转换为 DDL 语句。 右侧文本框用于输入 SQL 语句,点击“Run SQL▶️”执行,执行结果显示在页面下方;“Run SQL▶️”可以选择输出结果的格式,包括表格、普通文本 以及 Markdown 三种格式。 另外,复制网页地址可以分享本次测试的数据和结果,以上截图的地址为:http://sqlfiddle.com/#!9/a6c585/1。 地址:http://sqlfiddle.com/ DB Fiddle DB Fiddle 提供了

How can i call a function that return a BOOLEAN using MyBatis?

混江龙づ霸主 提交于 2021-02-11 13:02:04
问题 i'm using MyBatis to call a function in a PL SQL database. The function have one of the OUT parameter as BOOLEAN like this: FUNCTION f_foo_function(foo IN VARCHAR, foo_output OUT BOOLEAN, error OUT VARCHAR2) My problem is when i try to call the function from my xml mapper, every try i do mybatis don't recognize the boolean output and throw me and error like incompatible types. Also when i try to test the function from PLSQL Developer it make a convertion like this :pout_boolean_result := sys

sql order by with group by rollup

≯℡__Kan透↙ 提交于 2021-02-11 12:58:05
问题 My query looks like below with the foll. output Current Output Role Cases prepped % Completed State Member 1 10 5 50% State Member 2 10 7 70% State President 10 2 20% Summary 30 14 46.6% Output Expected Role Cases prepped % Completed State President 10 2 20% State Member 1 10 5 50% State Member 2 10 7 70% Summary 30 14 46% Roles table id name 30 State President 40 State Member This is my query, SELECT COALESCE(ROLE, 'Summary') ROLE, count(*) AS cases, SUM(CASE WHEN PREPARED = 'Y' THEN 1 ELSE

sql order by with group by rollup

こ雲淡風輕ζ 提交于 2021-02-11 12:57:15
问题 My query looks like below with the foll. output Current Output Role Cases prepped % Completed State Member 1 10 5 50% State Member 2 10 7 70% State President 10 2 20% Summary 30 14 46.6% Output Expected Role Cases prepped % Completed State President 10 2 20% State Member 1 10 5 50% State Member 2 10 7 70% Summary 30 14 46% Roles table id name 30 State President 40 State Member This is my query, SELECT COALESCE(ROLE, 'Summary') ROLE, count(*) AS cases, SUM(CASE WHEN PREPARED = 'Y' THEN 1 ELSE

Oracle) Insert multiple rows with one fixed value

ぃ、小莉子 提交于 2021-02-11 12:54:12
问题 I'd like to insert these values in the following fashion: insert into table (name, action-id) values ('user', select action from actions where name='user2'); The result being: Inserts along the line of, ('user', 1) ('user', 2) ('user', 3) I'm noticing this isn't correct sql. How would I go about accomplishing this? note) select action from actions where name='user2' would return: (1, 2, 3) 回答1: You can do it with a loop: BEGIN FOR x IN (select action from actions where name='user2') LOOP

Sql Script file (apex_epg_config.sql) is missing in Oracle Apex 20.2

风格不统一 提交于 2021-02-11 12:41:48
问题 I have Oracle Apex 20.1 Installed on Oracle Linux 6.10 Server with Oracle Database 12.2. Recently I am trying to update into Apex 20.2 but this script file (apex_epg_config.sql) is missing in zip folder. When I load the site then giving me this error: There is a problem with your environment because the Application Express files are not up-to-date! The files for version 20.1.0.00.13 have been loaded, but 20.2.0.00.20 is expected. Please verify that you have copied the images directory to your

Creating a new attribute in Oracle database from two other attributes

时光毁灭记忆、已成空白 提交于 2021-02-11 12:36:25
问题 I have a Classes table which is as follows: Classes(classid, dept_code, course#, sect#, year, semester, limit, class_size, room, TA_B#) The qeustion is: Find the classid, dept_code and course# of each undergraduate class (i.e., course# < 500) that was offered in Spring 2017. For each such class, also list the number of seats available (computed by limit – class_size) under the header “seats_available”. I tried this simple approach: select classes.classid, classes.dept_code, classes.course#,