SQL COPY Flashcards
Create an open database connection
$connection = new mysqli(“localhost”, “root”, “”, “”);
What is used to terminate an SQL statement?
;
Write SQL code to check for a connection error
if(mysqli_connect_errno()) {
echo “error message”
exit();
}
Give examples of SQL data types
SMALLINT
VARCHAR
FLOAT
DATE
Write SQL code to create a new database called school_info
$sql = "CREATE DATABASE school_info"; $result = $connection->query($sql)
What is Database Management Language?
Data manipulation language refers to a set of commands used for selecting, inserting, deleting and updating data
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)
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.
Write SQL code to close a database connection
mysqli_close($connection)
What does SQL stand for?
Structured Query language
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;
What is a Database Management System?
A collection of programs which enables its users to access the database and manipulate data
Write generic select SQL code
SELECT field
FROM table
WHERE search criteria
ORDER BY sort criteria;
Write generic SQL code to create a new database
$sql = "CREATE DATABASE dbname"; $result = $connection ->query($sql);
Write SQL code to close a database connection
mysqli_close($connection);