Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS 3630 Database Design and Implementation

Similar presentations


Presentation on theme: "CS 3630 Database Design and Implementation"— Presentation transcript:

1 CS 3630 Database Design and Implementation
Remove Test2 and Test1!

2 Assignment6-2 Any Questions?

3 Your Oracle Account UserName is the same as your UWP username
Followed Not case sensitive Initial Password: UserName3630 (all lower case) Example: yangq3630 Password is case sensitive Reset password required after the first login Do Not Use Any Special Characters such

4 Remember Your Password!
to HelpDesk at from your UWP account if you forget your new password

5 Oracle Client SQL*Plus
All labs in Ullrich Hall Not available from home or any other lab on campus

6 Structured Query Language (SQL)
One language for Relational Databases ANSI Standard Oracle: SQL*Plus MS SQL Server: Transact-SQL IBM DB2 MySQL Sybase ...

7 Structured Query Language (SQL)
Case insensitive (like VB) Free style (like C++ and Java) Statement terminator – semicolon (like C++ and Java) Programming Rule: Style Each clause of a query on a separate line When creating tables Each field on a separate line Each table constraint on a separate line

8 Structured Query Language (SQL)
DDL (Data Definition Language) Create Table (user) ... Drop Table (user) ... Alter Table (user) ... DML (Data Manipulation language) Select * From Branch … Insert into Branch ... Update branch ... Delete from BRANCH ...

9 Change Your Oracle Password inside Oracle
-- Oracle Command Prompt SQL> -- Change your password -- Remember your new password! SQL> Alter User yourUserName identified by newPassword; -- Every ANSI SQL standard command ends with ;

10 Change Your Oracle Password inside Oracle
-- Change your password SQL> password Changing password for USERNAME Old password: New password: Retype new password: Password changed SQL>

11 Oracle Data Types Char(size) fixed length string up to 2000 bytes
default is 1 byte blanks are padded on right when fewer chars entered Varchar2(size) variable size string must specify the limit (size) Varchar(size) same as Varchar2(size) better to use Varchar2

12 Oracle Data Types Integer, int, smallint Float Date
Valid dates from 1-Jan-4712 B.C. to 31-Dec-4712 A.D. Default format: DD-MON-YY 23-Mar-09 23-Mar-2009 Including time

13 Oracle Data Types Number(l, d) l: length (total) d: decimal digits
number (5, 2): largest value is Decimal(l, d), Numeric(l, d) same as number(l, d) SQL standard blob: binary large object, up to 4 GB clob: character large object, up to 4 GB raw(size): raw binary data, up to 2000 bytes ...

14 Create a Table SQL> Create Table Test1 ( C1 char(5) Primary Key,
C2 Varchar2(50), C3 Integer, C4 Date);

15 Show Table Schema SQL> Describe Test1 Or SQL> Desc Test1
Describe is a SQL*Plus command and no semicolon is required.

16 Insert Records Insert into Test1
Values (‘cs363', ‘s1', 44, ‘28-feb-12’); Values (‘cs334', ‘s2', 45, ‘29-feb-2012’); One record at a time! Single quotes for string Date is entered as string in the default format

17 Retrieve Records SQL> Select * From test1; Two records

18 Log Out SQL> exit

19 Log in SQL>

20 Retrieve Records SQL> Select * From test1; How many records?

21 Command Commit DDL commands are sent back to server and executed there
DML commands are executed at client site Use commit to send results back to server

22 Insert Records Insert into Test1
Values (‘cs363', ‘s1', 44, ‘28-feb-12’); Values (‘cs334', ‘s2', 45, ‘29-feb-2012’);

23 Command Commit SQL> Commit;

24 Log Out and Log In SQL> Select * From test1; How many records?

25 Update Records Update test1 Set c3 = 50 Where c1 = ‘cs363’;
-- Each clause on a separate line

26 Delete Records Delete from test1 Where c1 = ‘cs363’;
-- select to check Delete from test1; -- desc to check

27 Drop Table Drop table test1; Desc test1 -- to check ERROR:
ORA-04043: object test1 does not exist


Download ppt "CS 3630 Database Design and Implementation"

Similar presentations


Ads by Google