Demo Oracle Sql

User avatar
agibsonsw
SilverLounger
Posts: 2403
Joined: 05 Feb 2010, 22:21
Location: London ENGLAND

Demo Oracle Sql

Post by agibsonsw »

Hello.

I need to demonstrate and test a few expressions in Oracle SQL. I could use sqlfiddle but I'm struggling to create a textfile that would create a date-field in an acceptable format for Oracle. (Why does this fiddle put in triple-quotes """ ?)

Does anyone have, or could point me to, a sample create table statement, or a text file, that would enable me to create a small Oracle table with a few different data-types?

If anyone knows of an online tool that would assist me to test Oracle expressions, other than sqlfiddle.com, I look forward to hearing from you ;)
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.

User avatar
HansV
Administrator
Posts: 78484
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Demo Oracle Sql

Post by HansV »

I don't know anything about Oracle :flee:, but does the example in Creating Tables help?
Best wishes,
Hans

User avatar
HansV
Administrator
Posts: 78484
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Demo Oracle Sql

Post by HansV »

If you want to create a table and populate it with sample data, take a look at Create table with data type: VARCHAR2, Date, Number(8,2).
Best wishes,
Hans

User avatar
agibsonsw
SilverLounger
Posts: 2403
Joined: 05 Feb 2010, 22:21
Location: London ENGLAND

Re: Demo Oracle Sql

Post by agibsonsw »

Thank you @Hans, those links are very useful.

I was trying to follow the example (from the first link you provided) to insert multiple rows (code below) but I just this second realised that in sqlfiddle I need to run both of the following in one go, in the left-panel!! D'oh!

Anyway, I'm just posting the below in case it interests anyone ;)

Thanks Hans.

Code: Select all

INSERT ALL
INTO Staff
    (StaffNo, FirstName, LastName, Salary, Grade, OfficeID, Department, Extn, Bonus, 
      BonusRate, StartDate, EndDate)
VALUES (101, 'Cole', 'Russell', 22000, 6, 'LDN', 'SAL', 5525, 0, 0.03, DATE '1980-07-21', NULL)
INTO Staff
    (StaffNo, FirstName, LastName, Salary, Grade, OfficeID, Department, Extn, Bonus, 
      BonusRate, StartDate, EndDate)
VALUES 
    (104, 'Charlotte', 'Hill', 31500, 4, 'LEE', 'SAL', 3175, 1, 0.04, DATE '1980-12-01', NULL)
SELECT * FROM dual;
based on my table:

Code: Select all

CREATE TABLE Staff
 (
  StaffNo int PRIMARY KEY,
  FirstName varchar2(30) NOT NULL,

  LastName varchar2(30) NOT NULL,
  Salary number(7,2),

  Grade smallint,
  OfficeID varchar2(5) NOT NULL,
  Department varchar2(5),
  Extn smallint,
  Bonus smallint,

  BonusRate decimal(3,3),
  StartDate date,
  EndDate date

);
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.