






























Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!































*****************Test.java*******************
import java.sql.;*
class Test { public static void main (String args []) throws SQLException { // Load the Oracle JDBC driver DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
// Connect to the database Connection conn = DriverManager.getConnection (url,"username","password");
// Create a Statement Statement stmt = conn.createStatement ();
// Select the SYSDATE column from the dual table ResultSet rset = stmt.executeQuery ("select SYSDATE from dual");
// Print the result while (rset.next ()) System.out.println (rset.getString (1));
// Close the ResultSet rset.close();
// Close the Statement stmt.close();
// Close the connection conn.close(); } }
Introduction to Oracle
Introduction to SQL
Introduction to SQL(Cont’d)
In order to communicate with the database, SQL supports the following categories of commands:-
SQL*Plus
SQLPlus is an Oracle specific program which accepts SQL commands and PL/SQL blocks and executes them. SQLPlus enables manipulation of SQL commands and PL/SQL blocks. It performs many additional tasks as well.
Oracle Basics
Data Definition Language
SQL> CREATE TABLE <table_name> ( <column1_name> <data_type> <[not]null>, <column2_name> <data_type> <[not]null>,
.... CONSTRAINT pk_name PRIMARY KEY (column_name); CONSTRAINT fk_name FOREIGN KEY (column_name)); REFERENCE name1(name2) ON DELETE CASCADE);
Data Definition Language(Cont’d)
SQL>DROP <table_name>;