WorksheetsNodejs: Database SQL
Total questions: 10
Worksheet time: 5mins
What is the correct syntax to create a table on MySQL
CREATE TABLE <tablename>
CREATE ENTITY <tablename>
CREATE COLLECTION <tablename>
CREATE RECORD <tablename>
Replace the missing word:
CREATE TABLE departments (
name _____ NOT NULL
)
varchar(255)
string(255)
letters(255)
words(255)
Choose the correct option to create a field with a default time stamp
created_at datetime DEFAULT CURRENT
created_at datetime DEFAULT TIMESTAMP
created_at datetime DEFAULT CURRENT_TIMESTAMP
created_at datetime DEFAULT TIME
How would we represent a column referencing another table as the a foreign key?
FOREIGN KEY (department_id) REFERENCES departments(id)
FOREIGN KEY departments(id)
REFERENCES (department_id),
FOREIGN KEY REFERENCES
departments(id)
(department_id),
FOREIGN KEY
REFERENCES
(department_id) departments(id)
Which syntax is correct for setting enum constraints?
status ('active', 'inactive') ENUM
ENUM status ('active', 'inactive')
('active', 'inactive') status ENUM
status ENUM ('active', 'inactive')
To create a record into a users table, what would be the correct syntax?
insert from users (name) values ("stephen")
insert into users (name) values ("stephen")
insert where users (name) values ("stephen")
insert when users (name) values ("stephen")
We want to get the records for all users, but we want only their names. Choose the right option?
select * from users
select id from users
select from users where name
select name from users
Choose the correct syntax to update the name field for a user?
update name
from users
set name = 'new name'
where id = 1
update users
set name = 'new name'
update users
set name = 'new name'
where id = 1
update from users
set name = 'new name'
where id = 1
Select the appropriate delete syntax
delete users
where id = 1
delete from users
where id = 1
delete * from users
where id = 1
delete from users
We want to get all active users from our db. Select the right syntax?
select * from users
select * from users
where active = false
select * from users
where active = true
select * from users
where active = NULL
