deck_18323252 Flashcards
Another developer is trying to add a column named Prefix in a table by using the following query:
ALTER TABLE Person ADD Prefix varchar (4) NOT NULL;
The developer receives an error message after running the query. The developer is unable to remember the exact error message.
What is likely the cause of this problem?
You should run the DROP CONSTRAINT query before running the ALTER TABLE query
You need to create a report of data in the students table. The report must meet the following requirements:
- Display all students who enrolled on or after June 1, 2020
- Display all students who graduated in 2022.
- Return the result set in order of enrollment, with the most
recent enrollment date first.
enrollment_date specifies the enrollment date.
graduation _date specifies the graduation date.
An academic _status of Graduated indicates that a student has
graduated.
Which query should you use?
SELECT * FROM students WHERE enrollment_date >= ‘2020-06-01’ OR academic_status = ‘Graduated’ AND graduation_date >= ‘2020-01-01’ ORDER BY enrollment_date DESC
How many rows are returned by the SQL query on the Cars table?
a. 4
Which statement deletes a Customer record with ID 12345?
D. DELETE FROM Customer WHERE CustomerID = 12345
Which SQL statement is a DML operation?
C. INSERT INTO Employee VALUES (‘Jack Smith’)
Which query retrieves items with ‘chocolate’ in the description?
D. SELECT ItemName, Price FROM Products WHERE ItemDescription LIKE ‘%chocolate%’
Which statement creates a composite key?
A. CREATE TABLE Order (OrderID INTEGER, OrderItemID INTEGER, PRIMARY KEY (OrderID, OrderItemID))
Structuring a table: Field uniqueness, row uniqueness, column name uniqueness.
False (field uniqueness), True (row uniqueness), True (column name uniqueness)
Recommended data type for financial amounts?
a. Decimal
Which statement updates Harry’s books in San Francisco?
D. UPDATE LoanedBooks SET Books = 0 WHERE (NAME = ‘Harry’ AND City = ‘San Francisco’)
Which statement returns the number of rows in a table?
D. SELECT COUNT(*) FROM Employee
How to display total points per player on TeamID 1?
SELECT PlayerID, SUM(Points) FROM PlayerStat WHERE TeamID = 1 GROUP BY PlayerID
Which object ensures valid SalesPerson records in the Sales table?
B. Foreign key
How to create the NorthAmericanMammals view?
CREATE VIEW [dbo].[NorthAmericanMammals View] AS SELECT a.Id, a.Name FROM Animal a WHERE a.Class = ‘Mammals’ AND a.InNorthAmerica = 1
What happens to a view after deleting its underlying data?
d. Empty
Which keyword returns rows appearing in both result sets?
b. INTERSECT
A reason to create a stored procedure?
c. Improve performance
First normal form requirements?
a. Exclude duplicate rows; c. Exclude repeating groups
Which join includes all customers and those with no orders?
a. Full join
Query to select top 10 uninspected buildings?
SELECT TOP 10 FROM Building WHERE InspectionDate IS NULL ORDER BY InspectionDate
Assign data types to StudentName, GradeLevel, DaysAbsent?
StudentName VARCHAR; GradeLevel INT; DaysAbsent DECIMAL
Update ProductCategory for spoons?
A. UPDATE Product SET ProductCategory = 43 WHERE ProductDescription = ‘spoon’
Term for ProductID and ProductCategory relationship?
e. functionally dependent
Result of SELECT without JOIN?
d. Cartesian product