Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query statement

Status
Not open for further replies.

lytheon

Programmer
Sep 23, 2003
4
NL
I have a question about a query statement.

I like the statement to display the following:

the query needs to get all columns from the current table
with some facts like (data length, datatype,does the column have a constraint and if it has to which table)

I already have the statement in oracle:
String query = "SELECT distinct data_type, data_length
, uc.constraint_type, substr(uc.r_constraint_name, 4) as foreigntabel
, column_id
FROM
(
user_tab_columns utc
LEFT OUTER JOIN user_cons_columns ucc ON ucc.column_name = utc.column_name
And
ucc.table_name = utc.table_name
and
ucc.CONSTRAINT_NAME
in (
select constraint_name
from
user_constraints
where constraint_type
in ('C','P','R')
)
)
LEFT OUTER JOIN user_constraints uc
ON uc.constraint_name = ucc.constraint_name
WHERE utc.table_name = UPPER('"+tableName+"')
ORDER BY column_id asc, constraint_type asc";

can someone help me to rewrite the statement to MYSQL?

thanx in advanced

with kind regards Lytheon
 
You can't get both data and metadata from MySQL in one query.

I recommend you get the data using a select query, issue a &quot;DESCRIBE <tablename>&quot; query, and then using the two in conjunction programmatically.

Want the best answers? Ask the best questions: TANSTAAFL!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top