Which SQL statement is used to create a new database?
A
MAKE DATABASE B
BUILD DATABASE C
CREATE DATABASE D
NEW DATABASE
Analysis & Theory
The correct SQL command to create a database is `CREATE DATABASE`.
Which function is used in PHP to execute SQL queries like CREATE DATABASE?
A
mysqli_connect() B
mysqli_query() C
mysqli_fetch_array() D
mysqli_close()
Analysis & Theory
`mysqli_query()` executes SQL commands such as `CREATE DATABASE`.
What is the correct SQL to create a table named `students` with columns `id` and `name`?
A
MAKE TABLE students (id INT, name VARCHAR(50)); B
CREATE TABLE students (id INT, name VARCHAR(50)); C
NEW TABLE students (id INT, name VARCHAR(50)); D
BUILD TABLE students (id INT, name VARCHAR(50));
Analysis & Theory
The correct SQL syntax is `CREATE TABLE students (id INT, name VARCHAR(50));`.
What will this PHP code do?
```
$sql = 'CREATE DATABASE myDB';
mysqli_query($conn, $sql);
```
A
Create a database named myDB B
Delete the database C
Create a table D
Insert data
Analysis & Theory
This code creates a new database called `myDB`.
Which SQL constraint is commonly used to auto-increment IDs in a table?
A
AUTO_COUNT B
INCREMENT C
AUTO_INCREMENT D
COUNT_ID
Analysis & Theory
`AUTO_INCREMENT` is used to automatically increase the value of ID columns.
What is the output if the database already exists and you run `CREATE DATABASE myDB;`?
A
Creates it anyway B
Error: Database exists C
Deletes and recreates D
Renames it
Analysis & Theory
An error occurs unless you use `CREATE DATABASE IF NOT EXISTS myDB;`.
What does this code do?
```
$sql = 'CREATE TABLE users (
id INT AUTO_INCREMENT PRIMARY KEY,
username VARCHAR(50) NOT NULL
)';
mysqli_query($conn, $sql);
```
A
Creates a database B
Creates a table `users` with columns `id` and `username` C
Deletes a table D
Inserts data
Analysis & Theory
This creates a `users` table with columns `id` (auto-increment primary key) and `username`.
Which data type is suitable for storing email addresses in a table?
A
INT B
VARCHAR C
DATE D
BOOLEAN
Analysis & Theory
`VARCHAR` is used for string data like email addresses.
Which clause prevents table creation errors if the table already exists?
A
IF FOUND B
IF TRUE C
IF NOT EXISTS D
IF CREATED
Analysis & Theory
`CREATE TABLE IF NOT EXISTS` prevents errors if the table already exists.
Why is `PRIMARY KEY` used when creating tables?
A
To create a backup key B
To uniquely identify each row C
To lock the table D
To delete duplicates automatically
Analysis & Theory
The `PRIMARY KEY` constraint uniquely identifies each row in the table.