Your query doesn't select for primary key, or constraint columns. select cl.table_name, cl.column_name, cl.constraint_name from user_cons_columns cl, user_constraints c where cl.table_name=3Dc.table_name and cl.constraint_name=3Dc.constraint_name and c.constraint_type=3D'P' and cl.table_name=3D'MATERIAL' order by cl.table_name,cl.position / Oh, and unless you created the table using mixed case (double-quoting around the table name in the create statement), Oracle will store it in upper case. On 6/8/05, Kean Jacinta <jacintakean@xxxxxxxxx> wrote: > Hi , >=20 > I am trying to get the table primary key and the > column name. How can i query that. >=20 > THis is the result i want : >=20 > table_name columns_name constraint_name > ---------- ------------- --------------- > Material bookid bookid_pk >=20 >=20 > currently i have tried >=20 > select u.table_name, u.column_name, c.constraint_name > from user_tab_columns u, user_constraints c > where u.table_name=3Dc.user_constraints > and u.table_name=3D'Material' >=20 > I can't get the result correctly >=20 >=20 >=20 >=20 >=20 >=20 >=20 >=20 >=20 > __________________________________ > Discover Yahoo! > Find restaurants, movies, travel and more fun for the weekend. Check it o= ut! > http://discover.yahoo.com/weekend.html >=20 > -- > //www.freelists.org/webpage/oracle-l > -- //www.freelists.org/webpage/oracle-l