SQL Flashcards Preview

AH Computing > SQL > Flashcards

Flashcards in SQL Deck (20):
1

Create an open database connection

$connection = new mysqli("localhost", "root", "", "");

2

What is used to terminate an SQL statement?

;

3

Write SQL code to check for a connection error

if(mysqli_connect_errno()) {
echo "error message"
exit();
}

4

Give examples of SQL data types

SMALLINT
VARCHAR
FLOAT
DATE

5

Write SQL code to create a new database called school_info

$sql = "CREATE DATABASE school_info";
$result = $connection->query($sql)

6

What is Database Management Language?

Data manipulation language refers to a set of commands used for selecting, inserting, deleting and updating data

7

Create a new table in SQL that is called pupils and contains a student id, name, class and has student id as a primary key

$sql = "CREATE TABLE pupils(studentid INT(1) NOT NULL, name VARCHAR(40), class VARCHAR(10) PRIMARY KEY(studentid))";
$result = $connection->query($sql)

8

What is the SELECT command used for?

It is used to pull data from the database to be displayed or to be processed in some way outwith the database.

9

Write SQL code to close a database connection

mysqli_close($connection)

10

What does SQL stand for?

Structured Query language

11

Write SQL code to perform an implicit inner join on two tables student_grades and students, displaying all results where the student_grades id is the same the students id

SELECT * FROM student_grades, students WHERE student_grades.Id = students.Id;

12

What is a Database Management System?

A collection of programs which enables its users to access the database and manipulate data

13

Write generic select SQL code

SELECT field
FROM table
WHERE search criteria
ORDER BY sort criteria;

14

Write generic SQL code to create a new database

$sql = "CREATE DATABASE dbname";
$result = $connection ->query($sql);

15

Write SQL code to close a database connection

mysqli_close($connection);

16

Write generic delete SQL code

DELETE FROM table
WHERE deletion criteria;

17

Write generic update SQL code

UPDATE table
SET attributes to be updated
WHERE update criteria;

18

Write generic insert SQL code

INSERT INTO table(attribute1, attribute2) VALUES(value1, value2):

19

Write generic equi-join SQL code

SELECT table1.attribute, table2.attribute
FROM table1, table2
WHERE table1.attribute = table2.attribute;

20

Write generic database connection

$connection = new mysqli("localhost","username","password", "database");