1. Home
  2. Explore
  3. Computer Science
  4. SQL Basics

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

SQL Basics

  • 39Unfamiliar
  • 0Learning
  • 0Familiar
  • 0Mastered
Topic: Database Concepts

What does SQL stand for?

39 questions

  1. 1

    What does SQL stand for?

    1. A

      Simple Query Language

    2. B

      Sequential Query Language

    3. C

      Standard Query Language

    4. D

      Structured Query Language

    Correct answer
    D

    Structured Query Language

    Explanation

    SQL is an acronym for Structured Query Language, used to communicate with databases.

  2. 2

    What is the primary purpose of SQL?

    1. A

      To design user interfaces

    2. B

      To manage operating systems

    3. C

      To communicate with databases

    4. D

      To create spreadsheets

    Correct answer
    C

    To communicate with databases

    Explanation

    SQL is a language designed specifically for managing and querying data in relational databases.

  3. 3

    What does DBMS stand for?

    1. A

      Data Basic Manipulation System

    2. B

      Data Backup Management System

    3. C

      Database Maintenance System

    4. D

      Database Management System

    Correct answer
    D

    Database Management System

    Explanation

    DBMS stands for Database Management System, software that manages databases.

  4. 4

    Which of the following best describes a relational database?

    1. A

      A database that uses unstructured data

    2. B

      A database that stores data in a single table

    3. C

      A database managed by a spreadsheet program

    4. D

      A database with tables that are related to each other through keys

    Correct answer
    D

    A database with tables that are related to each other through keys

    Explanation

    Relational databases organize data into tables that are linked via primary and foreign keys.

  5. 5

    Which of the following is an example of a non-relational database?

    1. A

      Oracle

    2. B

      MySQL

    3. C

      NoSQL

    4. D

      PostgreSQL

    Correct answer
    C

    NoSQL

    Explanation

    NoSQL databases are non-relational, while the others are relational database management systems.

  6. 6

    In a database table, what is a record?

    1. A

      A row

    2. B

      A column

    3. C

      A field

    4. D

      A table

    Correct answer
    A

    A row

    Explanation

    A record is a single row in a table, containing data for each column.

  7. 7

    What are the four basic operations in SQL collectively called?

    1. A

      QUAD

    2. B

      CRUD

    3. C

      FECT

    4. D

      SQL

    Correct answer
    B

    CRUD

    Explanation

    CRUD stands for Create, Read, Update, Delete — the four fundamental database operations.

  8. 8

    Which of the following is NOT a relational database management system?

    1. A

      Microsoft SQL Server

    2. B

      MySQL

    3. C

      NoSQL

    4. D

      PostgreSQL

    Correct answer
    C

    NoSQL

    Explanation

    NoSQL is a type of non-relational database, not a specific RDBMS.

  9. 9

    What character must every SQL command end with in MySQL?

    1. A

      Comma (,)

    2. B

      Colon (:)

    3. C

      Semicolon (;)

    4. D

      Period (.)

    Correct answer
    C

    Semicolon (;)

    Explanation

    In MySQL, a semicolon signals the end of a command; otherwise the interpreter waits for more input.

  10. 10

    Which command is used to display all databases in MySQL?

    1. A

      LIST DATABASES

    2. B

      DISPLAY DATABASES

    3. C

      GET DATABASES

    4. D

      SHOW DATABASES

    Correct answer
    D

    SHOW DATABASES

    Explanation

    The SHOW DATABASES command lists all databases on the server.

  11. 11

    What does the USE command do in MySQL?

    1. A

      Selects a database to work with

    2. B

      Shows the current database

    3. C

      Deletes a database

    4. D

      Creates a new database

    Correct answer
    A

    Selects a database to work with

    Explanation

    The USE command sets the active database for subsequent commands.

  12. 12

    How do you access the MySQL prompt after installation on Linux (as shown in the video)?

    1. A

      sudo mysql-server

    2. B

      mysql

    3. C

      sudo mysql

    4. D

      mysql start

    Correct answer
    C

    sudo mysql

    Explanation

    The video used 'sudo mysql' to access the MySQL prompt with root privileges.

  13. 13

    Which command installs the MySQL server on Ubuntu?

    1. A

      sudo apt install mysql-workbench

    2. B

      sudo apt install mysql-server

    3. C

      sudo apt install mysql

    4. D

      sudo apt install mysql-client

    Correct answer
    B

    sudo apt install mysql-server

    Explanation

    The correct package for the MySQL server is 'mysql-server'.

  14. 14

    How do you verify that the MySQL service is running?

    1. A

      sudo systemctl enable mysql

    2. B

      sudo systemctl start mysql

    3. C

      sudo mysql status

    4. D

      sudo systemctl status mysql

    Correct answer
    D

    sudo systemctl status mysql

    Explanation

    The status command shows whether the service is active and running.

  15. 15

    Which command creates a new database named 'test_db'?

    1. A

      MAKE DATABASE test_db;

    2. B

      CREATE DATABASE test_db;

    3. C

      ADD DATABASE test_db;

    4. D

      NEW DATABASE test_db;

    Correct answer
    B

    CREATE DATABASE test_db;

    Explanation

    The correct syntax is CREATE DATABASE followed by the database name.

  16. 16

    When creating a table, what is the purpose of specifying a data type for each column?

    1. A

      To define the kind of data that can be stored in that column

    2. B

      To create an index on the column

    3. C

      To determine the column's position in the table

    4. D

      To set a default value for the column

    Correct answer
    A

    To define the kind of data that can be stored in that column

    Explanation

    Data types restrict what values can be entered (e.g., INT for integers, VARCHAR for strings).

  17. 17

    Which data type would you use to store a whole number in MySQL?

    1. A

      VARCHAR

    2. B

      TEXT

    3. C

      BOOLEAN

    4. D

      INT

    Correct answer
    D

    INT

    Explanation

    INT is used for integer (whole number) values.

  18. 18

    What does VARCHAR(255) mean in a column definition?

    1. A

      The column stores exactly 255 characters

    2. B

      The column can store up to 255 characters of text

    3. C

      The column is a boolean value

    4. D

      The column stores numbers up to 255

    Correct answer
    B

    The column can store up to 255 characters of text

    Explanation

    VARCHAR(n) stores variable-length strings with a maximum length of n characters.

  19. 19

    Which command provides information about the columns of a table?

    1. A

      SHOW COLUMNS

    2. B

      DESCRIBE table_name

    3. C

      VIEW table_name

    4. D

      DISPLAY table_name

    Correct answer
    B

    DESCRIBE table_name

    Explanation

    DESCRIBE (or DESC) lists column names, types, and other details for the specified table.

  20. 20

    What is the term for the structure that defines how a database is organized?

    1. A

      Format

    2. B

      Schema

    3. C

      Blueprint

    4. D

      Layout

    Correct answer
    B

    Schema

    Explanation

    A schema defines the tables, columns, data types, and relationships in a database.

  21. 21

    In a CREATE TABLE statement, how are column definitions separated?

    1. A

      With periods

    2. B

      With spaces

    3. C

      With semicolons

    4. D

      With commas

    Correct answer
    D

    With commas

    Explanation

    Commas separate each column definition inside the parentheses.

  22. 22

    Which command is used to add new rows to a table?

    1. A

      UPDATE

    2. B

      INSERT INTO

    3. C

      ADD INTO

    4. D

      CREATE

    Correct answer
    B

    INSERT INTO

    Explanation

    INSERT INTO adds one or more rows to a table.

  23. 23

    In an INSERT INTO statement, how are the values listed?

    1. A

      In square brackets

    2. B

      In curly braces

    3. C

      In quotes separated by spaces

    4. D

      In parentheses after the VALUES keyword

    Correct answer
    D

    In parentheses after the VALUES keyword

    Explanation

    The syntax is INSERT INTO table VALUES (value1, value2, ...);

  24. 24

    What does the UPDATE command do?

    1. A

      Modifies existing records

    2. B

      Adds new records

    3. C

      Deletes records

    4. D

      Creates a new table

    Correct answer
    A

    Modifies existing records

    Explanation

    UPDATE changes the values of existing rows in a table.

  25. 25

    To delete specific rows from a table, which clause is used with DELETE FROM?

    1. A

      ORDER BY

    2. B

      WHERE

    3. C

      LIMIT

    4. D

      HAVING

    Correct answer
    B

    WHERE

    Explanation

    The WHERE clause specifies which rows to delete; without it, all rows are removed.

  26. 26

    When using UPDATE, which keyword specifies the new value for a column?

    1. A

      SET

    2. B

      INTO

    3. C

      VALUE

    4. D

      ASSIGN

    Correct answer
    A

    SET

    Explanation

    The SET keyword assigns new values to the specified columns.

  27. 27

    What happens if you omit the WHERE clause in a DELETE statement?

    1. A

      All rows in the table are deleted

    2. B

      The table itself is deleted

    3. C

      An error occurs

    4. D

      Only the first row is deleted

    Correct answer
    A

    All rows in the table are deleted

    Explanation

    DELETE without a WHERE clause removes every row from the table.

  28. 28

    What does the asterisk (*) mean in a SELECT statement?

    1. A

      Select distinct values

    2. B

      Select only the first column

    3. C

      Multiply the values

    4. D

      Select all columns

    Correct answer
    D

    Select all columns

    Explanation

    SELECT * returns all columns from the specified table.

  29. 29

    Which clause is used to filter rows in a SELECT statement?

    1. A

      HAVING

    2. B

      IF

    3. C

      WHERE

    4. D

      FILTER

    Correct answer
    C

    WHERE

    Explanation

    The WHERE clause specifies conditions that rows must meet to be included in the result.

  30. 30

    How do you select only the 'name' column from a table called 'coffee'?

    1. A

      SELECT name FROM coffee;

    2. B

      SELECT * FROM coffee WHERE name;

    3. C

      SELECT coffee.name;

    4. D

      SELECT column name FROM coffee;

    Correct answer
    A

    SELECT name FROM coffee;

    Explanation

    To select specific columns, list them after SELECT, separated by commas.

  31. 31

    Which operator combines multiple conditions in a WHERE clause when both must be true?

    1. A

      AND

    2. B

      XOR

    3. C

      NOT

    4. D

      OR

    Correct answer
    A

    AND

    Explanation

    AND requires all conditions to be true for a row to be included.

  32. 32

    How do you sort query results in ascending order?

    1. A

      ORDER BY column_name DESC

    2. B

      ORDER BY column_name ASC

    3. C

      SORT BY column_name ASC

    4. D

      ORDER column_name ASC

    Correct answer
    B

    ORDER BY column_name ASC

    Explanation

    ORDER BY with ASC (ascending) sorts from smallest to largest.

  33. 33

    What does DESC stand for in an ORDER BY clause?

    1. A

      Descending

    2. B

      Descriptor

    3. C

      Design

    4. D

      Description

    Correct answer
    A

    Descending

    Explanation

    DESC sorts in descending order, from largest to smallest.

  34. 34

    Which query returns all rows from 'avengers' where origin is 'Earth' or 'Asgard'?

    1. A

      Both a and c

    2. B

      SELECT * FROM avengers WHERE origin = 'Earth' AND origin = 'Asgard';

    3. C

      SELECT * FROM avengers WHERE origin IN ('Earth', 'Asgard');

    4. D

      SELECT * FROM avengers WHERE origin = 'Earth' OR origin = 'Asgard';

    Correct answer
    A

    Both a and c

    Explanation

    Both the OR operator and the IN clause can achieve this filter; AND would require both conditions which is impossible.

  35. 35

    What command is used to add a new column to an existing table?

    1. A

      MODIFY TABLE table_name ADD column_name data_type;

    2. B

      ALTER TABLE table_name ADD column_name data_type;

    3. C

      UPDATE TABLE table_name ADD column_name data_type;

    4. D

      CHANGE TABLE table_name ADD column_name data_type;

    Correct answer
    B

    ALTER TABLE table_name ADD column_name data_type;

    Explanation

    ALTER TABLE with ADD clause adds a new column to the table structure.

  36. 36

    In the video, what data type is used for a boolean (true/false) column?

    1. A

      BOOLEAN

    2. B

      TINYINT

    3. C

      BIT

    4. D

      BOOL

    Correct answer
    A

    BOOLEAN

    Explanation

    The video used 'boolean' as the data type for the beard column.

  37. 37

    In a relational database, what is the role of a primary key?

    1. A

      To index the table for performance

    2. B

      To create a relationship between tables

    3. C

      To uniquely identify each row in a table

    4. D

      To define the data type of a column

    Correct answer
    C

    To uniquely identify each row in a table

    Explanation

    A primary key uniquely identifies each record; it is a column or set of columns with unique values.

  38. 38

    What is a foreign key in a relational database?

    1. A

      A key that is unique across the entire database

    2. B

      A key that is optional for each table

    3. C

      A key that links two tables together

    4. D

      A key that is used for encryption

    Correct answer
    C

    A key that links two tables together

    Explanation

    A foreign key in one table references the primary key of another table, creating a relationship.

  39. 39

    What is the purpose of a JOIN in SQL?

    1. A

      To combine rows from two or more tables based on a related column

    2. B

      To delete records that match a condition

    3. C

      To update records in a join table

    4. D

      To insert data into multiple tables at once

    Correct answer
    A

    To combine rows from two or more tables based on a related column

    Explanation

    JOINs allow you to retrieve data from multiple related tables in a single query.

Question 1 of 39
Question 1 of 39

Ask anything

We've read this whole study set, so questions about it get the best answers.

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent