- Compose an SQL CREATE statement that builds a table to hold television schedule listings. Make sure it has fields for the date, time, channel, and program name. Also, make sure it has a primary key and constraints to prevent nonsensical data (such as two shows at the same time on the same channel, or a show with no time or date).
An example might look like this:
CREATE TABLE tv_schedule AS (
id INTEGER PRIMARY KEY,
channel TEXT NOT NULL,
date DATE NOT NULL,
time TIME NOT NULL,
program TEXT NOT NULL,
UNIQUE(channel, date, time)
)
- The following SQL query is returning a syntax error; can you fix it?
DELETE * FROM my_table IF category_id == 12;
There are several problems here:
-
- DELETE does not take a field list, so * must be removed.
- IF is the wrong keyword. It should use WHERE.
- == is not an SQL operator. Unlike Python, SQL...