SQL COPY Flashcards

1
Q

Create an open database connection

A

$connection = new mysqli(“localhost”, “root”, “”, “”);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is used to terminate an SQL statement?

A

;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Write SQL code to check for a connection error

A

if(mysqli_connect_errno()) {
echo “error message”
exit();
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Give examples of SQL data types

A

SMALLINT
VARCHAR
FLOAT
DATE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Write SQL code to create a new database called school_info

A
$sql = "CREATE DATABASE school_info";
$result = $connection->query($sql)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is Database Management Language?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

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

A
$sql = "CREATE TABLE pupils(studentid INT(1) NOT NULL, name VARCHAR(40), class VARCHAR(10) PRIMARY KEY(studentid))";
$result = $connection->query($sql)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is the SELECT command used for?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Write SQL code to close a database connection

A

mysqli_close($connection)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What does SQL stand for?

A

Structured Query language

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

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

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is a Database Management System?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Write generic select SQL code

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Write generic SQL code to create a new database

A
$sql = "CREATE DATABASE dbname";
$result = $connection ->query($sql);
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Write SQL code to close a database connection

A

mysqli_close($connection);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Write generic delete SQL code

A

DELETE FROM table

WHERE deletion criteria;

17
Q

Write generic update SQL code

A

UPDATE table
SET attributes to be updated
WHERE update criteria;

18
Q

Write generic insert SQL code

A

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

19
Q

Write generic equi-join SQL code

A

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

20
Q

Write generic database connection

A

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