Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Nodejs: Database SQL

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

What is the correct syntax to create a table on MySQL

a)

CREATE TABLE <tablename>

b)

CREATE ENTITY <tablename>

c)

CREATE COLLECTION <tablename>

d)

CREATE RECORD <tablename>

2.

Replace the missing word:

CREATE TABLE departments (
name _____ NOT NULL
)

a)

varchar(255)

b)

string(255)

c)

letters(255)

d)

words(255)

3.

Choose the correct option to create a field with a default time stamp

a)

created_at datetime DEFAULT CURRENT

b)

created_at datetime DEFAULT TIMESTAMP

c)

created_at datetime DEFAULT CURRENT_TIMESTAMP

d)

created_at datetime DEFAULT TIME

4.

How would we represent a column referencing another table as the a foreign key?

a)

FOREIGN KEY (department_id) REFERENCES departments(id)

b)

FOREIGN KEY departments(id)

REFERENCES (department_id),

c)

FOREIGN KEY REFERENCES

departments(id)

(department_id),

d)

FOREIGN KEY

REFERENCES

(department_id) departments(id)

5.

Which syntax is correct for setting enum constraints?

a)

status ('active', 'inactive') ENUM

b)

ENUM status ('active', 'inactive')

c)

('active', 'inactive') status ENUM

d)

status ENUM ('active', 'inactive')

6.

To create a record into a users table, what would be the correct syntax?

a)

insert from users (name) values ("stephen")

b)

insert into users (name) values ("stephen")

c)

insert where users (name) values ("stephen")

d)

insert when users (name) values ("stephen")

7.

We want to get the records for all users, but we want only their names. Choose the right option?

a)

select * from users

b)

select id from users

c)

select from users where name

d)

select name from users

8.

Choose the correct syntax to update the name field for a user?

a)

update name
from users
set name = 'new name'

where id = 1

b)

update users

set name = 'new name'

c)

update users

set name = 'new name'
where id = 1

d)

update from users

set name = 'new name'

where id = 1

9.

Select the appropriate delete syntax

a)

delete users

where id = 1

b)

delete from users
where id = 1

c)

delete * from users
where id = 1

d)

delete from users

10.

We want to get all active users from our db. Select the right syntax?

a)

select * from users

b)

select * from users
where active = false

c)

select * from users

where active = true

d)

select * from users

where active = NULL