Showing posts with label SQL bites. Show all posts
Showing posts with label SQL bites. Show all posts

Thursday, February 18, 2010

Oracle PL/SQL queries 3 - How to see invalid view or other objects in the database

To find invalid view, table, java class, procedure, etc in a table, use 'select * from all_objects where object_type = 'invalid';

Wednesday, February 17, 2010

Oracle PL/SQL queries 2 - How to see list of tables in your database?

Since some programming languages' command for desc is !== database command for desc, you cannot use 'desc <table>' to see a database table's columns when coding.

Instead you should use, select * from user_tables;

If you need the column/size of a specific table:

select * from user_tab_columns where table_name = <table name>

Monday, February 8, 2010

Oracle PL/SQL queries 1 - How to see the indexes created in your Database

Assuming that you are given the user role - 'whatever' and your database is called 'arschloch', if you want to see what indexes are created on which tables in the 'arschloch' database, use:

USER_IND_COLUMNS - COLUMNs comprising user's INDEXes and INDEXes on user's TABLES (user being 'whatever' in this context):
INDEX_NAME
Index name
TABLE_NAME
Table or cluster name
COLUMN_NAME
Column name or attribute of object column
COLUMN_POSITION
Position of column or attribute within index
COLUMN_LENGTH
Maximum length of the column or attribute,in bytes
CHAR_LENGTH
Maximum length of the column or attribute,in characters
DESCEND
DESC if this column is sorted descending on disk,otherwise ASC

i.e. select index_name, table_name, column_name from user_ind_column where rownum <5;

LinkWithin

Related Posts with Thumbnails