database-metadata

How to retrieve sequences metadata from JDBC?

放肆的年华 提交于 2019-12-05 08:53:25
I am trying to retrieve different kind of metadata of my Oracle DB from Java code (using basic JDBC). For example, if I want to retrieve the list of tables with _FOO suffix, I can do something like: Connection connection = dataSource.getConnection(); DatabaseMetaData meta = connection.getMetaData(); ResultSet tables = meta.getTables(connection.getCatalog(), null, "%_FOO", new String[] { "TABLE" }); // Iterate on the ResultSet to get information on tables... Now, I want to retrieve all the sequences from my database (for example all sequence named S_xxx_FOO ). How would I do that, as I don't

JDBC automatical query turned to be very slow

拥有回忆 提交于 2019-12-04 13:03:57
问题 I am maintaining an application creating an Oracle DB via JDBC. Starting from today this query: SELECT NULL AS pktable_cat , p.owner AS pktable_schem, p.table_name AS pktable_name , pc.column_name AS pkcolumn_name, NULL AS fktable_cat , f.owner AS fktable_schem, f.table_name AS fktable_name , fc.column_name AS fkcolumn_name, fc.position AS key_seq , NULL AS update_rule , DECODE (f.delete_rule, 'CASCADE', 0, 'SET NULL', 2, 1) AS delete_rule , f.constraint_name AS fk_name , p.constraint_name AS

How to get all trigger names from a database using Java JDBC?

故事扮演 提交于 2019-12-04 04:16:57
问题 I'd like to retrieve all trigger names from an Oracle database schema. I use getFunctions to retrieve all functions but i can't find another one for the triggers. DatabaseMetaData dbmd; ResultSet result = dbmd.getFunctions(null, Ousername, null); 回答1: You can do it using metadata. DatabaseMetaData dbmd = dbConnection.getMetaData(); ResultSet result = dbmd.getTables("%", Ousername, "%", new String[]{ "TRIGGER" }); while (result.next()) { result.getString("TABLE_NAME") } 回答2: The JDBC API does

How to find out when data was inserted to Postgres?

╄→гoц情女王★ 提交于 2019-12-04 01:47:06
I have inherited an existing Postgres database full of data. Most of the data has a 'created_date' column value. Some of the earlier data was inserted before this was being tracked. Is there a Postgres metadata table hidden away somewhere that tracks when INSERT queries were done? Postgres 9.5 or later You can enable track_commit_timestamp in postgresql.conf (and restart) to start tracking commit timestamps. Then you can get a timestamp for your xmin . Related answer: Atomically set SERIAL value when committing transaction Postgres 9.4 or older There is no such metadata in PostgreSQL unless

Difference between SYS.ALL_TAB_COLUMNS and SYS.ALL_TAB_COLS in Oracle 12c

淺唱寂寞╮ 提交于 2019-12-01 22:10:19
What is the difference between the ALL_TAB_COLUMNS and ALL_TAB_COLS system tables in Oracle 12c? In my DB, the ALL_TAB_COLUMNS has slightly fewer rows than ALL_TAB_COLS. From the Oracle manual for ALL_TAB_COLS This view differs from "ALL_TAB_COLUMNS" in that system-generated hidden columns and invisible columns, which are user-generated hidden columns, are not filtered out. From the Oracle manual for ALL_TAB_COLUMNS This view filters out system-generated hidden columns and invisible columns, which are user-generated hidden columns. The ALL_TAB_COLS view does not filter out hidden columns and

How to get all trigger names from a database using Java JDBC?

不羁的心 提交于 2019-12-01 20:29:19
I'd like to retrieve all trigger names from an Oracle database schema. I use getFunctions to retrieve all functions but i can't find another one for the triggers. DatabaseMetaData dbmd; ResultSet result = dbmd.getFunctions(null, Ousername, null); You can do it using metadata. DatabaseMetaData dbmd = dbConnection.getMetaData(); ResultSet result = dbmd.getTables("%", Ousername, "%", new String[]{ "TRIGGER" }); while (result.next()) { result.getString("TABLE_NAME") } The JDBC API does not provide a standard way to retrieve trigger information from the DatabaseMetaData. In fact, the word "trigger"

How can I get different datatypes from ResultSetMetaData in Java?

六月ゝ 毕业季﹏ 提交于 2019-11-30 08:01:09
I have a ResultSet that returns data of different types. The query is constructed dynamically so, at compile time, I don't know what type of value the query will return. I have written the following code assuming that all results are Strings. But I want to get the type of each value too. How can I do this? Below is the code I have written. while (reportTable_rst.next()) { String column = reportTable_rst.getString(columnIterator); } At this point, I would like to get the column type, and get the value according to the data type. The ResultSetMetaData.getColumnType(int column) returns a int

How can I get different datatypes from ResultSetMetaData in Java?

梦想与她 提交于 2019-11-29 10:55:25
问题 I have a ResultSet that returns data of different types. The query is constructed dynamically so, at compile time, I don't know what type of value the query will return. I have written the following code assuming that all results are Strings. But I want to get the type of each value too. How can I do this? Below is the code I have written. while (reportTable_rst.next()) { String column = reportTable_rst.getString(columnIterator); } At this point, I would like to get the column type, and get

JDBC DatabaseMetaData.getColumns() returns duplicate columns

荒凉一梦 提交于 2019-11-29 01:24:03
I'm busy on a piece of code to get alle the column names of a table from an Oracle database. The code I came up with looks like this: DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver()); Connection conn = DriverManager.getConnection( "jdbc:oracle:thin:@<server>:1521:<sid>", <username>, <password>); DatabaseMetaData meta = conn.getMetaData(); ResultSet columns = meta.getColumns(null, null, "EMPLOYEES", null); int i = 1; while (columns.next()) { System.out.printf("%d: %s (%d)\n", i++, columns.getString("COLUMN_NAME"), columns.getInt("ORDINAL_POSITION")); } When I ran this code

How to find out when a particular table was created in Oracle?

佐手、 提交于 2019-11-27 18:08:12
In Oracle, is there a way to find out when a particular table was created? Similarly, is there a way to find out when a particular row was inserted/last updated? SELECT created FROM dba_objects WHERE object_name = <<your table name>> AND owner = <<owner of the table>> AND object_type = 'TABLE' will tell you when a table was created (if you don't have access to DBA_OBJECTS, you could use ALL_OBJECTS instead assuming you have SELECT privileges on the table). The general answer to getting timestamps from a row, though, is that you can only get that data if you have added columns to track that