primarykey auslesen (jdbc)

Seite 1 von 1 - Forum: Coding Stuff auf overclockers.at

URL: https://www.overclockers.at/coding-stuff/primarykey_auslesen_jdbc_99905/page_1 - zur Vollversion wechseln!


sensei schrieb am 28.11.2003 um 19:35

hi!

hab das problem, dass ich aus einer tabelle via JDBC den primary key auslesen möchte, ich wühl mich jetzt schon a zeiterl durch oracle 9i manual find aber nix vernünftiges :(
sowas wie getPrimarykey FROM table :]


tia


edit: also den namen der spalte die schlüssel ist möcht ich wissen.


watchout schrieb am 29.11.2003 um 07:05

ich hab ja keinen plan, aber kannst du da nicht sql verwenden?

Code:
SHOW INDEX FROM table;
du kriegst zwar mehr info raus... ;)


atrox schrieb am 29.11.2003 um 13:06

watchout> hier get es um oracle !

sensi>
select i.table_name, u.column_name, i.index_name, i.index_type, i.uniqueness, i.status from user_indexes i, user_ind_columns u where i.index_name=u.index_name;

das sind alle indexes für alle deine tabellen, wenn du sie nur für eine bestimmte willst, mußt halt noch where klauseln hinzufügen. aber vorsicht: oracle macht bei mehreren uniquie indeces auf eine tabelle keinen unterschied, war 'primary' ist, oder nicht.


watchout schrieb am 29.11.2003 um 14:43

oh darn, lass mich raten dass von mir gegebene is wieder so ne mysql-only gschicht? gut dass es im handbuch net steht...
egal, sollte jemand mal gleiches problem bei mysql haben, siehe oben :rolleyes:


crashman schrieb am 29.11.2003 um 14:47

So gehts gehts auch

SELECT COL.CONSTRAINT_NAME,COL.COLUMN_NAME,CON.CONSTRAINT_TYPE
FROM USER_CONS_COLUMNS COL, USER_CONSTRAINTS CON
WHERE COL.TABLE_NAME = upper('mitarbeiter')
AND COL.TABLE_NAME = CON.TABLE_NAME
AND COL.CONSTRAINT_NAME = CON.CONSTRAINT_NAME
AND CON.CONSTRAINT_TYPE='P';

mitarbeiter heissts halt bei mir




overclockers.at v4.thecommunity
© all rights reserved by overclockers.at 2000-2026