database-metadata

JDBC DatabaseMetaData.getColumns() returns duplicate columns

跟風遠走 提交于 2019-11-27 15:53:09
问题 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

How to get all columns' names for all the tables in MySQL?

青春壹個敷衍的年華 提交于 2019-11-26 21:16:15
Is there a fast way of getting all column names from all tables in MySQL , without having to list all the tables? select * from information_schema.columns where table_schema = 'your_db' order by table_name,ordinal_position suganya To list all the fields from a table in MySQL: select * from information_schema.columns where table_schema = 'your_DB_name' and table_name = 'Your_tablename' SELECT * FROM information_schema.columns WHERE table_schema = DATABASE() ORDER BY table_name, ordinal_position Since I don't have enough rep to comment, here's a minor improvement (in my view) over nick rulez's

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

梦想的初衷 提交于 2019-11-26 19:18:03
问题 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? 回答1: 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

How to get all columns&#39; names for all the tables in MySQL?

那年仲夏 提交于 2019-11-26 07:54:16
问题 Is there a fast way of getting all column names from all tables in MySQL , without having to list all the tables? 回答1: select * from information_schema.columns where table_schema = 'your_db' order by table_name,ordinal_position 回答2: To list all the fields from a table in MySQL: select * from information_schema.columns where table_schema = 'your_DB_name' and table_name = 'Your_tablename' 回答3: SELECT * FROM information_schema.columns WHERE table_schema = DATABASE() ORDER BY table_name, ordinal

Get Database Table Name from Entity Framework MetaData

五迷三道 提交于 2019-11-26 01:59:12
问题 I\'m trying to figure out a way to get the underlying SQL table name for a given entity type. I\'ve experimented around with the MetadataWorkspace queries and while I can get lots of information from the object or the storage space, I can\'t seem to figure out how to map between the two. So say I have a type in the object model called Lookup - how do I find the tablename (wws_lookups) in the database? I can query all the EntityType objects for CSpace and SSpace and I can see both listed

List of foreign keys and the tables they reference

断了今生、忘了曾经 提交于 2019-11-26 01:05:46
问题 I\'m trying to find a query which will return me a list of the foreign keys for a table and the tables and columns they reference. I am half way there with SELECT a.table_name, a.column_name, a.constraint_name, c.owner FROM ALL_CONS_COLUMNS A, ALL_CONSTRAINTS C where A.CONSTRAINT_NAME = C.CONSTRAINT_NAME and a.table_name=:TableName and C.CONSTRAINT_TYPE = \'R\' But I still need to know which table and primary key are referenced by this key. How would I get that? 回答1: The referenced primary

List of foreign keys and the tables they reference

人盡茶涼 提交于 2019-11-26 00:22:43
I'm trying to find a query which will return me a list of the foreign keys for a table and the tables and columns they reference. I am half way there with SELECT a.table_name, a.column_name, a.constraint_name, c.owner FROM ALL_CONS_COLUMNS A, ALL_CONSTRAINTS C where A.CONSTRAINT_NAME = C.CONSTRAINT_NAME and a.table_name=:TableName and C.CONSTRAINT_TYPE = 'R' But I still need to know which table and primary key are referenced by this key. How would I get that? Vincent Malgrat The referenced primary key is described in the columns r_owner and r_constraint_name of the table ALL_CONSTRAINTS . This