Oracle

Create oracle scheduler job which runs daily

99封情书 提交于 2021-02-07 18:32:07
问题 I want to create oracle scheduler job which runs daily at 20:00 and runs for 30 minute. This job will delete the rows from KPI_LOGS table as this table contains large amount of data and it continues to grow. I have created the below script in oracle sql developer for such job but not sure if this is correct or not as i am new to scheduler job concept. BEGIN DBMS_SCHEDULER.CREATE_JOB ( job_name => '"RATOR_MONITORING"."CROP_KPI_LOGS"', job_type => 'PLSQL_BLOCK', job_action => 'DELETE FROM KPI

Access remote Oracle database with Powershell

折月煮酒 提交于 2021-02-07 18:27:30
问题 I need to be able to connect to an Windows 7 based Oracle server (32 bit, Oracle XE) which is on my network. The machine I need to connect from is running Windows 7 64 bit, with Powershell installed on both machines. I have installed the Oracle 32 bit client on my 64 bit machine and have SQL Developer installed on both machines. I want to create a script that connects the the Oracle database and runs a simple SELECT query. I can't get it to connect though. I have tried using ODAC (I think I

Find duplicate rows in database

会有一股神秘感。 提交于 2021-02-07 18:14:54
问题 How do find duplicate rows? If last_name is the duplicate field, I want to have to display last_name frst_name frst_name1 frst_name2 .... Any database will do, prefer oracle. 回答1: Assuming your server has GROUP_CONCAT because you didn't mention which one you're using: SELECT GROUP_CONCAT(first_name SEPARATOR ' ') FROM table GROUP BY last_name HAVING COUNT(first_name) > 1 回答2: This should work on pretty much every SQL dialect: SELECT last_name, first_name FROM names WHERE last_name IN ( SELECT

Are nested parentheses in the FROM clause valid Oracle SQL syntax?

别来无恙 提交于 2021-02-07 14:40:48
问题 Does this query use correct Oracle syntax? select * from ( ( ( dual a) ) ) where a.dummy = 'X'; It works in 11g and 12c but is it truly valid syntax? Or is this is just a compiler "mistake" that might be fixed in the future, causing the code the fail? I doubt this is the correct syntax for the following reasons: It doesn't seem to do anything other than add extra parentheses. Expressions like ((1+2)*3) can obviously benefit from nested parentheses but I don't see how they would ever help the

Are nested parentheses in the FROM clause valid Oracle SQL syntax?

こ雲淡風輕ζ 提交于 2021-02-07 14:39:29
问题 Does this query use correct Oracle syntax? select * from ( ( ( dual a) ) ) where a.dummy = 'X'; It works in 11g and 12c but is it truly valid syntax? Or is this is just a compiler "mistake" that might be fixed in the future, causing the code the fail? I doubt this is the correct syntax for the following reasons: It doesn't seem to do anything other than add extra parentheses. Expressions like ((1+2)*3) can obviously benefit from nested parentheses but I don't see how they would ever help the

Execute For Each Table in PLSQL

…衆ロ難τιáo~ 提交于 2021-02-07 14:26:16
问题 I want to the the number of records in all tables that match a specific name criteria. Here is the SQL I built Declare SQLStatement VARCHAR (8000) :=''; BEGIN SELECT 'SELECT COUNT (*) FROM ' || Table_Name || ';' INTO SQLStatement FROM All_Tables WHERE 1=1 AND UPPER (Table_Name) LIKE UPPER ('MSRS%'); IF SQLStatement <> '' THEN EXECUTE IMMEDIATE SQLStatement; END IF; END; / But I get the following error: Error at line 1 ORA-01422: exact fetch returns more than requested number of rows ORA-06512

Execute For Each Table in PLSQL

吃可爱长大的小学妹 提交于 2021-02-07 14:26:08
问题 I want to the the number of records in all tables that match a specific name criteria. Here is the SQL I built Declare SQLStatement VARCHAR (8000) :=''; BEGIN SELECT 'SELECT COUNT (*) FROM ' || Table_Name || ';' INTO SQLStatement FROM All_Tables WHERE 1=1 AND UPPER (Table_Name) LIKE UPPER ('MSRS%'); IF SQLStatement <> '' THEN EXECUTE IMMEDIATE SQLStatement; END IF; END; / But I get the following error: Error at line 1 ORA-01422: exact fetch returns more than requested number of rows ORA-06512

How to call a function with Rowtype parameter from a select statement in Oracle

浪子不回头ぞ 提交于 2021-02-07 13:58:39
问题 I have an oracle function which has an in parameter which is of rowtype of a table, from a select statement i need to pass the current row to this function so that it does some processing and returns a value. Is there a pseudo variable that can be used within the context of a select statement something equivalent to a old and new in trigger. I would like to do something like select *,function1(rowtype) from table1 I want to avoid passing multiple parameters, so the question should be seen in

How to run dbms_crypto functions in Oracle as regular user?

筅森魡賤 提交于 2021-02-07 13:55:18
问题 I have problem with using dbms_crypto.hash() function in Oracle. I connected to database server using sqlplus as "sys/passwd as sysdba", then I installed dbms_crypto package: @/home/oracle/app/oracle/product/11.2.0/dbhome_1/rdbms/admin/dbmsobtk.sql @/home/oracle/app/oracle/product/11.2.0/dbhome_1/rdbms/admin/prvtobtk.plb Grant execute on dbms_crypto to public; Grant execute on dbms_sqlhash to public; Grant execute on dbms_obfuscation_toolkit to public; Grant execute on dbms_obfuscation

Substring-indexing in Oracle

一世执手 提交于 2021-02-07 13:18:25
问题 I just found that our current database design is a little inefficient according to the SELECT queries we perform the most. IBANs are positional coordinates, according to nation-specific formats. Since we mostly perform JOIN s and WHERE s on a precise substring of IBAN columns in some tables, my question is about assigning an index to the substring(s) of a column Are we forced to add redundant and indexed columns to the table? Ie. add columns NATION_CODE , IBAN_CIN , IT_CIN , IT_ABI , IT_CAB ,