MoinMoin Logo
  • Comments
  • Immutable Page
  • Menu
    • Navigation
    • RecentChanges
    • FindPage
    • Local Site Map
    • Help
    • HelpContents
    • HelpOnMoinWikiSyntax
    • Display
    • Attachments
    • Info
    • Raw Text
    • Print View
    • Edit
    • Load
    • Save
  • Login

Navigation

  • Start
  • Sitemap
Revision 11 as of 2014-08-04 22:35:27
  • Oracle

Oracle

http://docs.oracle.com/cd/B19306_01/index.htm

JDBC driver for JDK 1.6 (ojdbc6.jar): http://download.oracle.com/otn/utilities_drivers/jdbc/11204/ojdbc6.jar

Maven local repository install

mvn install:install-file -DgroupId=com.oracle -DartifactId=ojdbc6 -Dversion=11.2.0.3 -Dpackaging=jar -Dfile=ojdbc6.jar -DgeneratePom=true

   1 <dependency>
   2     <groupId>com.oracle</groupId>
   3     <artifactId>ojdbc6</artifactId>
   4     <version>11.2.0.3</version>
   5 </dependency>

Get schemas in DB

   1 SELECT DISTINCT USERNAME FROM DBA_USERS;

Get columns from table

   1 SELECT * FROM ALL_IND_COLUMNS WHERE TABLE_NAME='XYZ';
   2 
   3 SELECT * FROM ALL_TAB_COLUMNS WHERE TABLE_NAME='AAA';

Get indexes from table

http://docs.oracle.com/cd/B19306_01/server.102/b14237/statviews_1069.htm

   1 SELECT index_name, table_owner, table_name, uniqueness FROM USER_INDEXES WHERE table_name = 'XYZ';
   2 SELECT index_name, table_owner, table_name, uniqueness FROM ALL_INDEXES WHERE table_name = 'XYZ';

Get code from stored procedure

   1 SELECT * FROM all_source WHERE name = 'myprocedure'
   2 ORDER BY owner,name,line

Show schema and table

   1 SELECT distinct owner,table_name 
   2 FROM all_tables
   3 ORDER BY owner,table_name;

Partinioning

http://www.orafaq.com/wiki/Interval_partitioning

http://docs.oracle.com/cd/E11882_01/server.112/e25523/part_admin005.htm

http://docs.oracle.com/cd/E11882_01/server.112/e25523/part_admin002.htm

   1 select table_name,partition_name,num_rows
   2 from user_tab_partitions
   3 where table_name='TEST';

Other views:

  • DBA_TAB_PARTITIONS
  • ALL_TAB_PARTITIONS
  • USER_TAB_PARTITIONS

Sequence creation

   1 CREATE SEQUENCE sample_seq  START WITH 1 INCREMENT BY 1;
   2 CREATE SEQUENCE sample_seq2 MINVALUE 1 START WITH 1 INCREMENT BY 1;
   3 SELECT * FROM ALL_SEQUENCES; -- show all sequences
   4 
  • MoinMoin Powered
  • Python Powered
  • GPL licensed
  • Valid HTML 4.01