1 / 10

More basics on DB access

More basics on DB access. Elke A. Rundensteiner. Working with the Data Server. Basic SQL Commands. CREATE TABLE student(sNum INTEGER,sName VARCHAR (30)); -- creates table student with two columns

jdeluca
Download Presentation

More basics on DB access

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. More basics on DB access Elke A. Rundensteiner

  2. Working with the Data Server

  3. Basic SQL Commands CREATE TABLE student(sNum INTEGER,sName VARCHAR (30)); -- creates table student with two columns INSERT INTO student VALUES (1, ‘Joe’); -- insert one row into the student table SELECT * FROM student; -- select all rows from student table DELETE FROM student; -- delete all rows in the student table DROP TABLE student; -- drop student table Purge recyclebin; -- purge recyclebin tables that get created. -- Only works if you are logged onto CCC1

  4. Saving your Interactive Session in SQLPlus • If you want to save your output to a file (for homework) • spool <fileName> • <executeCmds to create tables ...> • spool off;

  5. Running scripts in SQLPlus • To enter OS environment, use sqlplus command: Host • Now you can execute OS commands, like : cd.. , exit, etc.

  6. Running scripts in SQLPlus • Create a file in your file system in the current directory called : createTable.sql • @createTable -- executes the script • start createTable -- also executes the script

  7. Saving your Interactive Session in SQLPlus • If you want to save your output to a file (for homework) • spool <fileName> • <executeCmds to create tables ...> • spool off; • Similar to script in unix.

  8. Loading data from a text file • Create a table : • CREATE TABLE myTable1 (a int, b int); • Create data file, say: • sample.dat • Put data into the file : 1,11 2,22 3,33 4,44

  9. Loading from text file (Contd) • Create control file, say load.ctl LOAD DATA INFILE sample.dat INTO TABLE myTable1 FIELDS TERMINATED BY ‘,’ (a,b) • Invoke SQL Loader (from your UNIX shell): • $ sqlldr <user/password> control=load.ctl

  10. Building Interfaces • Call Level Interface • Perl – to build web interfaces • JDBC – Java, servlets, java swing, etc • Embedded SQL • C API (Pro*C) • C++API (Pro*C++) • Java API (SQLJ) [ Oracle ]

More Related