oracle11g

Deleting a large number of records using PL/SQL

一笑奈何 提交于 2020-01-14 01:40:33
问题 I want to delete a large number of records using PL/SQL. The records are identified by a DATE field that identifies the last time the record was modified. I don't want to consume too many resources, so I thought that I should limit the number of records that were being deleted and it seemed to me that the pseudo column ROWNUM could server that purpose. I then check the number of rows effected by the update and repeat until the number of rows effected is 0. I'm looking for a recommendation for

Deleting a large number of records using PL/SQL

旧巷老猫 提交于 2020-01-14 01:37:49
问题 I want to delete a large number of records using PL/SQL. The records are identified by a DATE field that identifies the last time the record was modified. I don't want to consume too many resources, so I thought that I should limit the number of records that were being deleted and it seemed to me that the pseudo column ROWNUM could server that purpose. I then check the number of rows effected by the update and repeat until the number of rows effected is 0. I'm looking for a recommendation for

JDBC with Spring slow metadata fetch Oracle

帅比萌擦擦* 提交于 2020-01-13 10:08:09
问题 I am using the Spring JdbcUtils.extractDatabaseMetaData() method to analyze the database. The function calls a callback and hands over a DatabaseMetaData object. This object provides the getColumns(String catalog, String schemaPattern, String tableNamePattern, String columnNamePattern) . I call it like this getColumns("",TABLE_OWNER_USERNAME,null,null) and get 400 columns as a result. These are exactly the results that I want, but the request takes over 1 minute. Can I somehow optimize this

Is COMMIT required after every EXECUTE IMMEDIATE?

风格不统一 提交于 2020-01-13 09:12:11
问题 I have multiple EXECUTE IMMEDIATE commands within one oracle procedure. EXECUTE IMMEDIATE 'DELETE FROM tbl1'; EXECUTE IMMEDIATE 'INSERT INTO tbl1...'; COMMIT; EXECUTE IMMEDIATE 'DELETE FROM tbl3'; EXECUTE IMMEDIATE 'INSERT INTO tbl3 ...'; COMMIT; EXECUTE IMMEDIATE 'DELETE FROM tbl4'; EXECUTE IMMEDIATE 'INSERT INTO tbl4 ...'; COMMIT; Do I need all of these COMMIT, or just at the end of the procedure? 回答1: The only times that you're really forced to commit, other thasn at the end of a business

Is COMMIT required after every EXECUTE IMMEDIATE?

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-13 09:11:05
问题 I have multiple EXECUTE IMMEDIATE commands within one oracle procedure. EXECUTE IMMEDIATE 'DELETE FROM tbl1'; EXECUTE IMMEDIATE 'INSERT INTO tbl1...'; COMMIT; EXECUTE IMMEDIATE 'DELETE FROM tbl3'; EXECUTE IMMEDIATE 'INSERT INTO tbl3 ...'; COMMIT; EXECUTE IMMEDIATE 'DELETE FROM tbl4'; EXECUTE IMMEDIATE 'INSERT INTO tbl4 ...'; COMMIT; Do I need all of these COMMIT, or just at the end of the procedure? 回答1: The only times that you're really forced to commit, other thasn at the end of a business

How to calculate difference between two dates in oracle 11g SQL

天大地大妈咪最大 提交于 2020-01-13 09:07:18
问题 When I am trying to calculate the date difference by using datediff function it showing that invalid identifier. SELECT DATEDIFF(day,'2008-08-05','2008-06-05') AS DiffDate from da_static_trade. Error : invalid identifier. Can you please tell me what is the function to calculate date difference. 回答1: There is no DATEDIFF() function in Oracle. On Oracle, it is an arithmetic issue select DATE1-DATE2 from table 回答2: Oracle support Mathematical Subtract - operator on Data datatype. You may

sql plus not opening after installing oracle 11g

情到浓时终转凉″ 提交于 2020-01-13 05:37:09
问题 I installed oracle 11g and im was trying to open sqlplus from command prompt but it is opening and closing in a fraction of second..I tried opening the sqlplus from the installed location as well. It still shows the same behaviour. Can anyone help me with a solution. I already uninstalled and installed the oracle twice for some other errors. Earlier it was working fine, but when I installed it the second time, sql plus is not opening . I appreciate any advice. Thanks 回答1: Manasa, If the error

Why CREATE TABLE AS SELECT is more faster than INSERT with SELECT

ぐ巨炮叔叔 提交于 2020-01-12 10:15:18
问题 I make a query with INNER JOIN and the result was 12 millions lines. I like to put this in a table. I did some tests and when I created the table using clause AS SELECT was more faster than, create the table first and run a INSERT with SELECT after. I don't understand why. Somebody can explain for me? Tks 回答1: If you use 'create table as select' (CTAS) CREATE TABLE new_table AS SELECT * FROM old_table you automatically do a direct-path insert of the data. If you do an INSERT INTO new_table AS

Transposing and aggregating Oracle column data

*爱你&永不变心* 提交于 2020-01-11 12:32:58
问题 I have the following data Base End RMSA Item 1 RMSA Item 2 RMSA Item 3 RMSB Item 1 RMSB Item 2 RMSC Item 4 I want to convert it to the following format Key Products RMSA;RMSB Item 1, Item 2 RMSA Item 3 RMSC Item 4 Basically, those with similar results should be grouped into 1 line. However, I can't seem to get it to work using listagg, etc since I'm grouping on two columns. Is there any way to do this with a direct Oracle query? 回答1: You can use listagg() window analytic function twice as

Transposing and aggregating Oracle column data

早过忘川 提交于 2020-01-11 12:32:32
问题 I have the following data Base End RMSA Item 1 RMSA Item 2 RMSA Item 3 RMSB Item 1 RMSB Item 2 RMSC Item 4 I want to convert it to the following format Key Products RMSA;RMSB Item 1, Item 2 RMSA Item 3 RMSC Item 4 Basically, those with similar results should be grouped into 1 line. However, I can't seem to get it to work using listagg, etc since I'm grouping on two columns. Is there any way to do this with a direct Oracle query? 回答1: You can use listagg() window analytic function twice as