★ Must-know
CREATE TABLE, listing each column and its type; declare a single-column primary key by adding PRIMARY KEY to that column.📌 A composite primary key is declared once at the end of the table, as
PRIMARY KEY (cin, codeAct); writingPRIMARY KEYseparately for each column is an error.
adherents table contains:
cin CHAR(8) as the primary keynom VARCHAR(30)prenom VARCHAR(30)email VARCHAR(40)age INTadresse VARCHAR(50)Further detail
Create and select a database with CREATE DATABASE name; followed by USE name;.
The activites table contains:
codeAct CHAR(4) as the primary keylibelle VARCHAR(30)tarif DECIMAL(6,3)places INT1. An `age` check uses `CHECK (age BETWEEN 12 AND 70)`. Which age is accepted by the constraint?
2. Which definition correctly specifies the `adherents` table’s columns and primary key?
3. A table has a column named adresse, which must be renamed ville and given the type VARCHAR(30); which ALTER TABLE operation does this?
How do you declare a single-column primary key when creating a table?
Add `PRIMARY KEY` to that column’s definition.
Which column is the primary key of the `adherents` table?
`cin CHAR(8)`.
Which fields and types make up the `adherents` table besides its primary key?
`nom VARCHAR(30)`, `prenom VARCHAR(30)`, `email VARCHAR(40)`, `age INT`, and `adresse VARCHAR(50)`.
How is the composite primary key `(cin, codeAct)` declared?
Once at the end of the table as `PRIMARY KEY (cin, codeAct)`.
Why is declaring `PRIMARY KEY` separately for each composite-key column an error?
A composite primary key must be declared once at the end of the table.
How does `ALTER TABLE` make a column mandatory using `MODIFY`?
Use `MODIFY column TYPE NOT NULL`, rewriting the column’s type.
It covers the core concepts of SQL Data Entry and Queries, organized by topic with the key definitions, explanations and takeaways, so it's easier to learn and remember.
Read the full study guide →The practice quiz has 17 multiple-choice questions, each with an explanation. Use it to check what you know and find your gaps.
Take the quiz (17 questions) →There are 39 flashcards on SQL Data Entry and Queries, with a question on the front and the answer on the back. Try to recall each answer before you flip, and let spaced repetition bring back the ones you miss.
See all 39 flashcards →Upload a PDF or paste your notes. Revizly writes a study guide, a practice quiz and flashcards in about a minute.