SQL Quiz 1

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

What is the correct code to remove row 3 from the student table?

DELETE FROM student WHERE id=3;

Which code is the correct way to update the GPA for the student in row 7 from the student table?

UPDATE student SET GPA=3.5 WHERE id=7;

What is the best way to return the number of rows in the student table?

SELECT COUNT (*) FROM student;

What is the function of an AS clause?

to name a column

Which statement is true about selecting columns in SQL?

Column names must be separated by commas.

The _____ statement is used to remove rows from a table.

DELETE

What is the purpose of a foreign key?

Foreign keys refer to the primary key in another table to link the two tables together. Foreign keys define the relationship between two tables.

The _____ statement is used to add a row to a table

INSERT

How can a row of data be inserted into a table named Animals?

INSERT INTO Animals (Name, Age, Type) VALUES ('Fido', 10, 'Dog');

Which statement would generate the fifth record in the following table?

INSERT INTO customer (name, city, state) VALUES ('Jimi Hendrix', 'Renton', 'WA');

Which statement is true about removing rows from a table?

Remove existing rows from a table with the DELETE FROM statement

Which SQL statement allows you to retrieve data from a SQL database?

SELECT

What is an example of a query to get only data containing the word "Apple"?

SELECT * FROM Fruits WHERE Name = 'Apple';

Which code returns the first 10 students who have a 4.0 GPA from the Grade table ordered alphabetically?

SELECT * FROM Grade WHERE GPA=4.0 ORDER BY Name LIMIT 10;

What is the proper syntax for aliasing a field?

SELECT FirstName AS "First Name";

The WHERE clause is used with UPDATE to determine which rows are updated.

TRUE

You can query columns in any order.

TRUE

You can use the COUNT(*) function to count all the rows in a table.

TRUE

Which clauses allow you to get rows and columns from a table in the database?

The SELECT statement retrieves data from the database by easily selecting the rows and columns from a table.

If you use UPDATE and SET without a WHERE clause, what happens?

The entire table is updated.

The _____ clause is used with SELECT to filter rows.

WHERE

Which statement is true about inserting data to a table?

You must execute the select statement after the insert into statement to see the result with the added row.

An SQL statement is terminated with _____

a semicolon

The SELECT statement is used for _____

all queries

How do you specify the columns to be selected?

by name or column heading

In the statement SELECT * FROM Customers WHERE Age > 50;, what is the formal name for FROM Customers?

clause (It modifies the verb `SELECT`)

What is a PRIMARY KEY?

the unique key for a table when exposed as a column

In the statement COUNT(*), what does the * mean

to consider all rows


Kaugnay na mga set ng pag-aaral

Software Interview Questions (C#)

View Set

Chapter 9: Pathways That Harvest Chemical Energy

View Set

KONSEP ALAM MELAYU DARI SEGI GEOGRAFI , BAHASA DAN BUDAYA

View Set

Intro to Health Informatics Final Study Guide

View Set

Power Engineering 4th Class Ch 114

View Set