CREATE TABLE Orders
(Order# NUMBER(4),
Customer# NUMBER(4),
OrderDate DATE NOT NULL,
ShipDate DATE,
ShipStreet VARCHAR2(18),
ShipCity...
CREATE TABLE Orders
(Order# NUMBER(4),
Customer# NUMBER(4),
OrderDate DATE NOT NULL,
ShipDate DATE,
ShipStreet VARCHAR2(18),
ShipCity VARCHAR2(15),
ShipState VARCHAR2(2),
ShipZip VARCHAR2(5),
ShipCost NUMBER(4,2),
CONSTRAINT orders_order#_pk PRIMARY KEY(order#),
CONSTRAINT orders_customer#_fk FOREIGN KEY (customer#)
REFERENCES customers(customer#));
INSERT INTO ORDERS
VALUES
(1000,1005,TO_DATE('31-MAR-09','DD-MON-YY'),TO_DATE('02-APR-09','DD-MON-YY'),'1201
ORANGE AVE', 'SEATTLE', 'WA', '98114' , 2.00);
INSERT INTO ORDERS
VALUES
(1001,1010,TO_DATE('31-MAR-09','DD-MON-YY'),TO_DATE('01-APR-09','DD-MON-YY'),
'114 EAST SAVANNAH', 'ATLANTA', 'GA', '30314', 3.00);
INSERT INTO ORDERS
VALUES
(1002,1011,TO_DATE('31-MAR-09','DD-MON-YY'),TO_DATE('01-APR-09','DD-MON-YY'),'58
TILA CIRCLE', 'CHICAGO', 'IL', '60605', 3.00);
INSERT INTO ORDERS
VALUES
(1003,1001,TO_DATE('01-APR-09','DD-MON-YY'),TO_DATE('01-APR-09','DD-MON-YY'),'958
MAGNOLIA LANE', 'EASTPOINT', 'FL', '32328', 4.00);...
Space X Bank
CREATE TABLE Branch(BranchIDNumber VARCHAR(15) PRIMARY KEY NOT
NULL, BranchName VARCHAR(6) NOT NULL, Address...
Space X Bank
CREATE TABLE Branch(BranchIDNumber VARCHAR(15) PRIMARY KEY NOT
NULL, BranchName VARCHAR(6) NOT NULL, Address VARCHAR(50) NOT NULL,
City TEXT NULL,
State CHAR(2) NULL, ZipCode INT(11) NOT NULL, OfficeNum VARCHAR(15)
NOT NULL, FaxNum VARCHAR(15) NOT NULL);
CREATE TABLE Employee(EmployeeIDNumber VARCHAR(15) NOT
NULL,FirstName VARCHAR(35) NOT NULL, LastName VARCHAR(35) NOT
NULL,
Email VARCHAR(100) NOT NULL, BranchIDNumber VARCHAR(11) NOT NULL,
FOREIGN KEY(BranchIDNumber) REFERENCES
Branch(BranchIDNumber),
JobTitle ENUM("Manager","Staff") NOT NULL, Salary DECIMAL(8, 2) NOT
NULL, HomeNumber VARCHAR(13) NULL, CellNumber VARCHAR(13) NOT
NULL);
CREATE TABLE...
Create a paid invoices table that has the same structure
as the invoices table, but it...
Create a paid invoices table that has the same structure
as the invoices table, but it does not need any
foreign key constraints (or other constraints, for that
matter) since data will be transferred into the paid table in order
to archive them out of the normal invoices table.
Invoices table:
create table invoices
(
invoice_id number(10),
vendor_id number(10) not null,
invoice_number varchar2(50) not null,
invoice_date date not null,
invoice_total number(9,2) not null,
payment_total number(9,2) default 0,
credit_total number(9,2) default...
Having below tables:
create table Student(sid char(10) primary key,
sname varchar(20) not null, gpa float, major...
Having below tables:
create table Student(sid char(10) primary key,
sname varchar(20) not null, gpa float, major char(10), dob
DATE);
create table Course(cno char(10) primary key,
cname varchar(20) not null, credits int, dept char(10));
create table Reg( sid references Student(sid) on delete
cascade,
cno references Course(cno) on delete cascade,
grade char(2),
primary key (sid, cno));
questions
For each course, display the number of students who got each
grade, ordered by the course and the letter grade.
List the current age in...
Write a script to create the following tables with attributes
as specified(SQL)
Customer table with Customer’s...
Write a script to create the following tables with attributes
as specified(SQL)
Customer table with Customer’s id, name, address, city as
varchar, customer’s date of birth as date type and zip code number
where the customers id is the primary key in the table, name and
date of birth are mandatory. Id has a 10-character limit, name,
address and city have a 50-character limit, zip has a 5-character
limit
Product Table with Product id, description and finish as
varchar, price...
-- Define the database
CREATE TABLE Product (
ProdName VARCHAR2(10) NOT NULL,
Price INTEGER NOT NULL,...
-- Define the database
CREATE TABLE Product (
ProdName VARCHAR2(10) NOT NULL,
Price INTEGER NOT NULL,
CONSTRAINT PRODUCT_PK PRIMARY KEY (ProdName)
);
CREATE TABLE Customer (
ID INTEGER NOT NULL,
ProdName VARCHAR2(10),
Rating INTEGER,
CustName VARCHAR2(10),
CONSTRAINT CUSTOMER_PK PRIMARY KEY (ID)
);
CREATE TABLE Buys (
ID INTEGER NOT NULL,
ProdName VARCHAR2(10) NOT NULL,
Quantity INTEGER NOT NULL,
CONSTRAINT BUYS_PK PRIMARY KEY (ID, ProdName)
);
ALTER TABLE Buys ADD CONSTRAINT PRODUCT_BUYS_FK
FOREIGN KEY (ProdName)
REFERENCES Product (ProdName)
NOT DEFERRABLE;
ALTER...
-- Table construction (just 1 simplest possible way)
CREATE TABLE PetType (
petTypeId VARCHAR(10) PRIMARY KEY,...
-- Table construction (just 1 simplest possible way)
CREATE TABLE PetType (
petTypeId VARCHAR(10) PRIMARY KEY,
animalType VARCHAR(20),
breed VARCHAR(20)
);
CREATE TABLE Owner (
ownerId VARCHAR(10) PRIMARY KEY,
firstName VARCHAR(20),
lastName VARCHAR(20) NOT NULL,
homePhoneNumber VARCHAR(20),
streetAddress VARCHAR(80),
suburb VARCHAR(20),
postcode VARCHAR(10)
);
CREATE TABLE Pet (
petId VARCHAR(10) PRIMARY KEY,
petName VARCHAR(20),
sex CHAR(1)
CHECK (sex IN ('M', 'F')),
petTypeId VARCHAR(10)
FOREIGN KEY REFERENCES PetType
);
CREATE TABLE PetAndOwner (
ownerId VARCHAR(10),
petId VARCHAR(10),
PRIMARY KEY (ownerId, petId),...
-- Drop the tables if they existDROP TABLE REP CASCADE
CONSTRAINTS;DROP TABLE CUSTOMER CASCADE CONSTRAINTS;DROP TABLE...
-- Drop the tables if they existDROP TABLE REP CASCADE
CONSTRAINTS;DROP TABLE CUSTOMER CASCADE CONSTRAINTS;DROP TABLE
ORDERS CASCADE CONSTRAINTS;DROP TABLE ITEM CASCADE CONSTRAINTS;DROP
TABLE ORDER_LINE CASCADE CONSTRAINTS;-- You are to change CUSTOMER
to CUSTOMERS for the Colonial database to avoid conflict with the
CUSTOMER table in Tal.-- Create the tablesCREATE TABLE REP(REP_NUM
CHAR(2) PRIMARY KEY,LAST_NAME CHAR(15),FIRST_NAME CHAR(15),STREET
CHAR(15),CITY CHAR(15),STATE CHAR(2),POSTAL_CODE CHAR(5),COMMISSION
DECIMAL(7,2),RATE DECIMAL(3,2) );CREATE TABLE CUSTOMER(CUSTOMER_NUM
CHAR(3) PRIMARY KEY,CUSTOMER_NAME CHAR(35) NOT NULL,STREET
CHAR(20),CITY CHAR(15),STATE CHAR(2),POSTAL_CODE CHAR(5),BALANCE
DECIMAL(8,2),CREDIT_LIMIT DECIMAL(8,2),REP_NUM CHAR(2) );CREATE...