More basics on DB access - PowerPoint PPT Presentation

About This Presentation
Title:

More basics on DB access

Description:

... use sqlplus command: Host Now you can execute OS commands, ... executes the script start createTable ... (from your UNIX shell): ... – PowerPoint PPT presentation

Number of Views:110
Avg rating:3.0/5.0
Slides: 11
Provided by: pcguest
Learn more at: http://web.cs.wpi.edu
Category:

less

Transcript and Presenter's Notes

Title: More basics on DB access


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 ltfileNamegt
  • ltexecuteCmds to create tables ...gt
  • 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
  • _at_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 ltfileNamegt
  • ltexecuteCmds to create tables ...gt
  • 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 ltuser/passwordgt controlload.ctl

10
Building Interfaces
  • Call Level Interface
  • Perl to build web interfaces
  • JDBC Java, servlets, java swing, etc
  • Embedded SQL
  • C API (ProC)
  • CAPI (ProC)
  • Java API (SQLJ) Oracle
Write a Comment
User Comments (0)
About PowerShow.com