A Guide to SQL
9th Edition
ISBN: 9781111527273
Author: Philip J. Pratt
Publisher: Course Technology Ptr
expand_more
expand_more
format_list_bulleted
Expert Solution & Answer
Chapter 3, Problem 12RQ
Explanation of Solution
Difference between “CHAR” and “VARCHAR”:
CHAR | VARCHAR |
“CHAR” is fixed length data type. | “VARCHAR” is the variable length data type. |
The storage size is equal to the maximum size of the column. | The storage size is equal to the actual length of the data. |
The keyword “CHAR” is used to declare the variable... |
Explanation of Solution
Appropriate place to use “CHAR” data type:
The “CHAR” data type is a good choice when storing the initial of the name as it takes up the same amount of bytes. It is also suitable to specify the name of the individual as it hold only the list of characters.
Example:
CREATE TABLE EMPLOYEE (
EMP_NU...
Explanation of Solution
URL:
The following given URL provides the examples as referen...
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
You will be using the Colonial Adventure Tours database. List the trip IDs and trip names for each pair of trips that have the same start location.(You will need to assign an alias). The first trip id should be the major sort key, and the second trip id should be the minor sort key.
This does not work:
CREATE OR REPLACE TRIGGER trg_char_hours
AFTER INSERT ON CHARTER
FOR EACH ROW
BEGIN
UPDATE AIRCRAFT
SET
AC_TTAF = AC_TTAF + NEW.CHAR_HOURS_FLOWN,
AC_TTEL = AC_TTEL + NEW.CHAR_HOURS_FLOWN,
AC_TTER = AC_TTER + NEW.CHAR_HOURS_FLOWN
WHERE AIRCRAFT.AC_NUMBER = NEW.AC_NUMBER;
END;
I get the following error:
ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'TRIGGER trg_char_hours AFTER INSERT ON CHARTER FOR EACH ROW BEGIN UPDATE AIRCRAF' at line 1
Here is the original question:
Create a trigger named trg_char_hours that automatically updates the AIRCRAFT table when a new CHARTER row is added. Use the CHARTER table’s CHAR_HOURS_FLOWN to update the AIRCRAFT table’s AC_TTAF, AC_TTEL, and AC_TTER values.
(Hint: use temp values, as the INSERT event does not accept the OLD keyword.)
Refer to the film and inventory tables of the Sakila database. The tables in this lab have the same columns and data types but fewer rows.
Write a query that lists the titles of films with the fewest rows in the inventory table.
This query requires a subquery that computes the minimum of counts by film_id:
SELECT MIN(count_film_id) FROM ( SELECT COUNT(film_id) AS count_film_id FROM inventory GROUP BY film_id ) AS temp_table;
This subquery is provided in the template.
Chapter 3 Solutions
A Guide to SQL
Ch. 3 - Prob. 1RQCh. 3 - How do you delete a table using SQL?Ch. 3 - Prob. 3RQCh. 3 - Prob. 4RQCh. 3 - Prob. 5RQCh. 3 - Prob. 6RQCh. 3 - Prob. 7RQCh. 3 - Prob. 8RQCh. 3 - Prob. 9RQCh. 3 - Prob. 10RQ
Ch. 3 - Prob. 11RQCh. 3 - Prob. 12RQCh. 3 - Prob. 13RQCh. 3 - Use SQL to complete the following exercises....Ch. 3 - Prob. 2TDCh. 3 - Prob. 3TDCh. 3 - Prob. 4TDCh. 3 - Prob. 5TDCh. 3 - Prob. 6TDCh. 3 - Prob. 7TDCh. 3 - Prob. 1CATCh. 3 - Add the following row to the ADVENTURE_TRIP table:...Ch. 3 - Prob. 3CATCh. 3 - Prob. 4CATCh. 3 - Prob. 5CATCh. 3 - Prob. 6CATCh. 3 - Review the data for the TRIP table in Figure 1-5...Ch. 3 - Colonial Adventure Tours would like to increase...Ch. 3 - Prob. 1SCGCh. 3 - Add the following record to the VACATION_UNIT...Ch. 3 - Delete the VACATION_UNIT table.Ch. 3 - Prob. 4SCGCh. 3 - Prob. 5SCGCh. 3 - Prob. 6SCGCh. 3 - The SERVICE_REQUEST table uses the CHAR data type...
Knowledge Booster
Similar questions
- The SERVICE_REQUEST table uses the CHAR data type for the DESCRIPTION and STATUS fields. Is there an alternate data type that could be used to store the values in these fields? Justify your reason for choosing an alternate data type or for leaving the data type as CHAR.arrow_forwardWhat happens if you try to decrease the scale or precision of a NUMBER column to a value less than the data already stored in the field?arrow_forwardWhich object in the data dictionary enables you to verify DEFAULT column settings? DEFAULT_COLUMNS DEF_TAB_COLUMNS USER_TAB_COLUMNS None of the abovearrow_forward
- In SQL Server, specify the differences between the two character data types as follows: NVARCHAR VARCHARarrow_forwardAccording to your student number and the following formula, please answer the corresponding questions in one single file. student number:170201034 if(yourStudentNumer % 3==0) select questions with X[0] lable if(yourStudentNumer % 3==1) select questions with X[1] lable if(yourStudentNumer % 3==2) select questions with X[2] lablearrow_forwardAccording to your student number and the following formula, please answer the corresponding questions in one single file. if(yourStudentNumer % 3==0) select questions with X[0] lable if(yourStudentNumer % 3==1) select questions with X[1] lable if(yourStudentNumer % 3==2) select questions with X[2] lablearrow_forward
- Suppose you have monthly data for ten years stored in the column ‘timeframe’. They are stored as characters in R. You want to change them to R dates called ‘Period’. Assuming the data structure is easily identified as a month/date, how should you do this?arrow_forwardBelow are some rows of the table INVOICE COD PROV_COD DATE TYPE LOC TOTAL 2910 192 2022-03-11 90 TX 1928 9301 384 2022-05-03 90 NY 2800 Overdue invoices are those whose date plus TYPE days have passed. Which of the following shows all invoices with overdue dates? a. SELECT * FROM INVOICE WHERE CURDATE() - DATE > TYPE b. SELECT * FROM INVOICE WHERE CURDATE()-TYPE >DATE c. SELECT * FROM INVOICE WHERE DATE+TYPE < CURDATE() d. SELECT * FROM INVOICE WHERE DATE+TYPE > CURDATE()arrow_forwardExplain why it would be preferable to use a DATE data type to store date data instead of a character data type.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- A Guide to SQLComputer ScienceISBN:9781111527273Author:Philip J. PrattPublisher:Course Technology PtrNp Ms Office 365/Excel 2016 I NtermedComputer ScienceISBN:9781337508841Author:CareyPublisher:Cengage
- Database Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781285196145Author:Steven, Steven Morris, Carlos Coronel, Carlos, Coronel, Carlos; Morris, Carlos Coronel and Steven Morris, Carlos Coronel; Steven Morris, Steven Morris; Carlos CoronelPublisher:Cengage LearningDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781305627482Author:Carlos Coronel, Steven MorrisPublisher:Cengage Learning
A Guide to SQL
Computer Science
ISBN:9781111527273
Author:Philip J. Pratt
Publisher:Course Technology Ptr
Np Ms Office 365/Excel 2016 I Ntermed
Computer Science
ISBN:9781337508841
Author:Carey
Publisher:Cengage
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781285196145
Author:Steven, Steven Morris, Carlos Coronel, Carlos, Coronel, Carlos; Morris, Carlos Coronel and Steven Morris, Carlos Coronel; Steven Morris, Steven Morris; Carlos Coronel
Publisher:Cengage Learning
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781305627482
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning