In SQL #1 Create a table called YOUR_NAME_BOAT containing the following fields:
ID: 3709340 • Letter: I
Question
In SQL
#1 Create a table called YOUR_NAME_BOAT containing the following fields:
Registration Number character 10 bytes Primary Key
Manufacturer character 20 bytes Not Null
Name character 20 bytes
Length numeric - three whole digits & one decimal point Not Null
Horsepower integer
* Registration numbers are in the format “NY 1234 FF” with embedded blanks and the first two letters identify the state
#2 Populate the table with five records.
#3 Change the horsepower field in the last record to a different value using a "where" clause to select the boat by its registration number
#4 Write a query and select all of the fields. Sort by the "length" field
Explanation / Answer
1) Table named JACK_BOAT is created based on the given fields and constraint. Create table statement is used.
CREATE TABLE JACK_BOAT
(
RegNum CHAR(10),
Maufacturer CHAR(20) NOT NULL,
Name CHAR(20),
Length NUMERIC(3,1) NOT NULL,
Horsepower INTEGER,
PRIMARY KEY (RegNum)
);
2) Inserting records to the table JACK_BOAT.
INSERT INTO JACK_BOAT VALUES ('NY 1234 FF', 'MAN123', 'ABC Manufacturer', 234.1, 12);
INSERT INTO JACK_BOAT VALUES ('NY 8734 FF', 'MAN342', 'XYZ Manufacturer', 544.3, 42);
INSERT INTO JACK_BOAT VALUES ('NY 1234 JJ', 'MAN657', 'RST Manufacturer', 894.1, 22);
3) Updating the Horsepower to to 25 for RegNum 'NY 1234 JJ'. Update table statement is used.
UPDATE JACK_BOAT
SET Horsepower = 25
WHERE RegNum = 'NY 1234 JJ';
4) Selecting all the fields from the JACK_BOAT table and sorting the result by Length. Order by is used to sort the result.
SELECT * FROM JACK_BOAT
ORDER BY Length;
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.