Homework 7 – Database Servers
- Question: (True/False) A relational database organizes data into tables with rows and columns.
- Question: (True/False) SQL stands for Structured Query Language.
- Question: (True/False) All databases use SQL as their query language.
- Question: What command is used to retrieve data from a SQL database?
- Question: What command is used to add new data to a SQL database table?
- Question: What command is used to modify existing data in a SQL database table?
- Question: What command is used to remove data from a SQL database table?
- Question: A foreign key is used to link two __ together.
- Question: (True/False) A database index improves data retrieval speed.
- Question: What command is used to grant permissions to a SQL database user?
- Question: What command is used to revoke permissions from a SQL database user?
- Question: (True/False) PostgreSQL is an open-source relational database management system.
- Question: (True/False) PostgreSQL uses
MySQL
as its default query language.
- Question: (True/False) PostgreSQL can handle both SQL and JSON queries.
- Question: What command is used to connect to a PostgreSQL database from the command line?
- Question: What flag allows you to specify the database name when connecting using
psql
?
- Question: What command lists all databases in PostgreSQL?
- Question: What command lists all tables in the current PostgreSQL database?
- Question: How do you create a new database named
testdb
in PostgreSQL?
- Answer:
CREATE DATABASE testdb;
- Question: How do you delete a database named
testdb
in PostgreSQL?
- Answer:
DROP DATABASE testdb;
- Question: What command creates a new user named
dbuser
with a password password123
?
- Answer:
CREATE USER dbuser WITH PASSWORD 'password123';
- Question: What command grants all privileges on a database named
testdb
to user dbuser
?
- Answer:
GRANT ALL PRIVILEGES ON DATABASE testdb TO dbuser;
- Question: What command revokes all privileges on
testdb
from dbuser
?
- Answer:
REVOKE ALL PRIVILEGES ON DATABASE testdb FROM dbuser;
- Question: What command starts the PostgreSQL service on a Linux system? Assume you are not the root user.
- Answer:
sudo systemctl start postgresql
- Question: What command stops the PostgreSQL service? Assume you are not the root user.
- Answer:
sudo systemctl stop postgresql
- Question: What command checks the status of the PostgreSQL service? Assume you are not the root user.
- Answer:
sudo systemctl status postgresql