Write a table creation script for a table called OWNER. Include the following:

• Column for the owner id; primary key
• Column for the owner username (i.e., the logon name); unique and not null
• Column for the owner’s first name; can be null
• Column for the owner’s last name; can be null
Determine the appropriate data types.
```
CREATE TABLE owner (
owner_id NUMBER NOT NULL
CONSTRAINT OWNER_PK PRIMARY KEY,
user_name VARCHAR2(30) NOT NULL
CONSTRAINT OWNER_UK1 UNIQUE,
first_name VARCHAR2(30) NULL,
last_name VARCHAR2(30) NULL)
```
a) Add a row to OWNER using the following values:
• Owner id = 20
• Owner username = Cartman_E
• Owner first name = Eric
• Owner last name = Cartman
b) Create a sequence called SEQ_OWNER. Write a SELECT statement to find out the highest value currently in the OWNER table. Start the sequence at that value plus one when you create it.
c) Add to OWNERS table all the entries in the STUDENT table using an INSERT INTO…SELECT. Use the sequence number to generate the owner id. Construct the owner username using string functions and appending the student id to insure uniqueness (use the format MORRISON_A_122).


a.
```
INSERT INTO owner
VALUES (20,'Cartman_E','Eric','Cartman')
COMMIT
```
b.
```
SELECT MAX(owner_id)
FROM owner

CREATE SEQUENCE seq_owner
START WITH 21
```
c.
```
INSERT INTO owner
SELECT seq_owner.NEXTVAL,
last_name||'_'||SUBSTR(first_name,1,1)||TO_CHAR(student_id),
first_name, last_name
FROM student


SELECT *
FROM owner
```

Computer Science & Information Technology

You might also like to view...

What are the techniques a transport protocol uses?

What will be an ideal response?

Computer Science & Information Technology

In inverse kinematics, a ____ is a link from one symbol instance to another or from one interior part of a shape to another.

A. bone B. muscle C. ligament D. ligature

Computer Science & Information Technology

In a simple peer-to-peer network, the network adapter can act as a network navigation device, but some networks require special devices to serve that purpose

Indicate whether the statement is true or false

Computer Science & Information Technology

When a company completes a background check, the company must comply with the ________ regulations

A) Privacy Act of 1974 B) Freedom of Information Act (FOIA) C) Fair Credit Reporting Act (FCRA) D) Free Flow of Information Act 2013

Computer Science & Information Technology