Chapter 11 Application Flashcards
Issue a command to create a database CS340.
Create database CS340;
Provide code to create a table named Implement within the current database.
(get specifications for column from notes)
create table implement( article varchar(21) NOT NULL UNIQUE, msrp decimal(6,2) DEFAULT 0.00, CATEGORY char(7) NOT NULL, quantity int(1) default 1);
Add a column named id, data type int, unsigned, not null with the auto_increment type attribute and designate the primary key.
Alter table implement add id int unsigned not null auto_increment primary key;
Alter the Implement column named msrp to change the name to price.
alter table implement change msrp Price decimal(6,2) Default 0.00;
Modify price to set width to 7 and the precision to 2 decimal places.
alter table implement modify price decimal (7,2) Default 0.00;
Add a column to implement with name vendorId, data type int, and width 3. The vendor column is to be a foreign key constraint that references a table named Vendor with corresponding column also named vendorId.
Alter table implement add vendorId int(3);
Alter table implement add constraint implement_fk_Vendor foreign key (vendorId) references Vendor (vendorId);
Code a statement to rename the implement table to TractorImplement.
rename table implement to TractorImplement;
Create an index based on the category column of TractorImplement/
create index TractorImplement_category on TractorImplement (category);