Functions | |
| void | getNodeAndChildren (const xmlpp::Node *node, std::ostream &textFromBodyFile, unsigned int indentation, std::set< std::string > &uniqueAttribs) |
| Get node of parsed html code and its children Gets unique attribues from html text. More... | |
| void | print_indentation (unsigned int indentation) |
| std::string | printNodeAndChildren (const xmlpp::Node *node) |
| Parse html code Save output in string. More... | |
| void | printNodeAndChildren (const xmlpp::Node *node, std::ofstream &textFromBodyFile) |
| Parse html code. More... | |
| std::size_t | write_data (void *ptr, std::size_t size, std::size_t nmemb, void *stream) |
| void getNodeAndChildren | ( | const xmlpp::Node * | node, |
| std::ostream & | textFromBodyFile, | ||
| unsigned int | indentation, | ||
| std::set< std::string > & | uniqueAttribs | ||
| ) |
Get node of parsed html code and its children Gets unique attribues from html text.
These attributes are hrefs from "<a href="">". This function is recursive.
| node | of xml/html structure |
| textFromBodyFile | html code |
| indentation | |
| uniqueAttribs | store attributes get from textFromBodyFile |
Definition at line 156 of file http_downloader.cpp.
| void print_indentation | ( | unsigned int | indentation | ) |
Definition at line 301 of file http_downloader.cpp.
| std::string printNodeAndChildren | ( | const xmlpp::Node * | node | ) |
Parse html code Save output in string.
| node | node of html structure |
Definition at line 220 of file http_downloader.cpp.
| void printNodeAndChildren | ( | const xmlpp::Node * | node, |
| std::ofstream & | textFromBodyFile | ||
| ) |
Parse html code.
| node | node of html structure |
| textFromBodyFile | output of parsing |
Definition at line 248 of file http_downloader.cpp.
| std::size_t write_data | ( | void * | ptr, |
| std::size_t | size, | ||
| std::size_t | nmemb, | ||
| void * | stream | ||
| ) |
Definition at line 29 of file http_downloader.cpp.


SQL is a standard language for storing, manipulating and retrieving data in databases.
Our SQL tutorial will teach you how to use SQL in: MySQL, SQL Server, MS Access, Oracle, Sybase, Informix, Postgres, and other database systems.
SQL is a standard language for accessing and manipulating databases.
What is SQL?
What Can SQL do?
Although SQL is an ANSI/ISO standard, there are different versions of the SQL language.
However, to be compliant with the ANSI standard, they all support at least the major commands (such as SELECT, UPDATE, DELETE, INSERT, WHERE) in a similar manner.
Note: Most of the SQL database programs also have their own proprietary extensions in addition to the SQL standard!
To build a web site that shows data from a database, you will need:
RDBMS stands for Relational Database Management System.
RDBMS is the basis for SQL, and for all modern database systems such as MS SQL Server, IBM DB2, Oracle, MySQL, and Microsoft Access.
The data in RDBMS is stored in database objects called tables. A table is a collection of related data entries and it consists of columns and rows.
Every table is broken up into smaller entities called fields. The fields in the Customers table consist of CustomerID, CustomerName, ContactName, Address, City, PostalCode and Country.
A record, also called a row, is each individual entry that exists in a table. For example, there are 91 records in the above Customers table. A record is a horizontal entity in a table.
A column is a vertical entity in a table that contains all information associated with a specific field in a table.
A database most often contains one or more tables. Each table is identified by a name (e.g. "Customers" or "Orders"). Tables contain records (rows) with data.
In this tutorial we will use the well-known Northwind sample database (included in MS Access and MS SQL Server).
The table above contains five records (one for each customer) and seven columns (CustomerID, CustomerName, ContactName, Address, City, PostalCode, and Country).
Most of the actions you need to perform on a database are done with SQL statements.
The following SQL statement selects all the records in the "Customers" table:
SQL keywords are NOT case sensitive: select is the same as SELECT
Some database systems require a semicolon at the end of each SQL statement.
Semicolon is the standard way to separate each SQL statement in database systems that allow more than one SQL statement to be executed in the same call to the server.
The SELECT statement is used to select data from a database.
The data returned is stored in a result table, called the result-set.
SELECT Syntax
Here, column1, column2, ... are the field names of the table you want to select data from. If you want to select all the fields available in the table, use the following syntax:
The following SQL statement selects the "CustomerName" and "City" columns from the "Customers" table:
SELECT CustomerName, City FROM Customers;
orSELECT CustomerName,City,ContactName FROM Customers;
The following SQL statement selects all the columns from the "Customers" table:
SELECT * FROM Customers;
The SELECT DISTINCT statement is used to return only distinct (different) values.
Inside a table, a column often contains many duplicate values; and sometimes you only want to list the different (distinct) values.
syntax:
SELECT DISTINCT Country FROM Customers; -- result is 21
SELECT Country FROM Customers; -- result is 91
The following SQL statement lists the number of different (distinct) customer countries:
SELECT COUNT(DISTINCT Country) FROM Customers; --- result is 1 and 21 items inside
Note: The example above will not work in Firefox! Because COUNT(DISTINCT column_name) is not supported in Microsoft Access databases. Firefox is using Microsoft Access in our examples.
Here is the workaround for MS Access:
The WHERE clause is used to filter records.
It is used to extract only those records that fulfill a specified condition.
WHERE Syntax
Note: The WHERE clause is not only used in SELECT statements, it is also used in UPDATE, DELETE, etc.!
The following SQL statement selects all the customers from the country "Mexico", in the "Customers" table:
above mentioned statement selects all records where in country column there is mentioned Mexico - 5 Records
SQL requires single quotes around text values (most database systems will also allow double quotes).
However, numeric fields should not be enclosed in quotes:
The following operators can be used in the WHERE clause:
The WHERE clause can be combined with AND, OR, and NOT operators.
The AND and OR operators are used to filter records based on more than one condition:
The NOT operator displays a record if the condition(s) is NOT TRUE.
The following SQL statement selects all fields from "Customers" where country is "Germany" AND city is "Berlin":
The following SQL statement selects all fields from "Customers" where city is "Berlin" OR "München":
The following SQL statement selects all fields from "Customers" where country is "Germany" OR "Spain":
The following SQL statement selects all fields from "Customers" where country is NOT "Germany":
You can also combine the AND, OR and NOT operators.
The following SQL statement selects all fields from "Customers" where country is "Germany" AND city must be "Berlin" OR "München" (use parenthesis to form complex expressions):
The following SQL statement selects all fields from "Customers" where country is NOT "Germany" and NOT "USA":
The ORDER BY keyword is used to sort the result-set in ascending or descending order.
The ORDER BY keyword sorts the records in ascending order by default. To sort the records in descending order, use the DESC keyword.
The following SQL statement selects all customers from the "Customers" table, sorted by the "Country" column:
The following SQL statement selects all customers from the "Customers" table, sorted DESCENDING by the "Country" column:
The following SQL statement selects all customers from the "Customers" table, sorted by the "Country" and the "CustomerName" column.
This means that it orders by Country, but if some rows have the same Country, it orders them by CustomerName:
The following SQL statement selects all customers from the "Customers" table, sorted ascending by the "Country" and descending by the "CustomerName" column:
The INSERT INTO statement is used to insert new records in a table.
INSERT INTO Syntax
it is possible to write the INSERT INTO statement in two ways:
The following SQL statement inserts a new record in the "Customers" table:
customers table has one more data injected in the table
Did you notice that we did not insert any number into the CustomerID field?
The CustomerID column is an auto-increment field and will be generated automatically when a new record is inserted into the table.
It is also possible to only insert data in specific columns.
The following SQL statement will insert a new record, but only insert data in the "CustomerName", "City", and "Country" columns (CustomerID will be updated automatically):
A field with a NULL value is a field with no value.
If a field in a table is optional, it is possible to insert a new record or update a record without adding a value to this field.
Then, the field will be saved with a NULL value.
Note: A NULL value is different from a zero value or a field that contains spaces. A field with a NULL value is one that has been left blank during record creation!
It is not possible to test for NULL values with comparison operators, such as =, <, or <>.
We will have to use the IS NULL and IS NOT NULL operators instead.
The IS NULL operator is used to test for empty values (NULL values).
The following SQL lists all customers with a NULL value in the "Address" field:
Tip: Always use IS NULL to look for NULL values.
The IS NOT NULL operator is used to test for non-empty values (NOT NULL values).
the following SQL lists all customers with a value in the "Address" field:
it gives filled data back
The UPDATE statement is used to modify the existing records in a table.
UPDATE Syntax
Note: Be careful when updating records in a table! Notice the WHERE clause in the UPDATE statement.
The WHERE clause specifies which record(s) that should be updated. If you omit the WHERE clause, all records in the table will be updated!
example
It is the WHERE clause that determines how many records will be updated.
The following SQL statement will update the ContactName to "Juan" for all records where country is "Mexico":
Be careful when updating records. If you omit the WHERE clause, ALL records will be updated!
The DELETE statement is used to delete existing records in a table.
syntax is following:
DELETE FROM table_name WHERE condition;
Note: Be careful when deleting records in a table! Notice the WHERE clause in the DELETE statement.
Note: Be careful when deleting records in a table! Notice the WHERE clause in the DELETE statement.
The WHERE clause specifies which record(s) should be deleted. If you omit the WHERE clause, all records in the table will be deleted!
The following SQL statement deletes the customer "Alfreds Futterkiste" from the "Customers" table:
DELETE FROM Customers WHERE CustomerName='Alfreds Futterkiste';
It is possible to delete all rows in a table without deleting the table. This means that the table structure, attributes, and indexes will be intact:
syntax is following:
DELETE FROM table_name;
The following SQL statement deletes all rows in the "Customers" table, without deleting the table:
DELETE FROM Customers;
The SELECT TOP clause is used to specify the number of records to return.
The SELECT TOP clause is useful on large tables with thousands of records. Returning a large number of records can impact performance.
Note: Not all database systems support the SELECT TOP clause. MySQL supports the LIMIT clause to select a limited number of records, while Oracle uses FETCH FIRST n ROWS ONLY and ROWNUM.
SQL Server / MS Access Syntax:
MySQL Syntax:
Oracle 12 Syntax:
the following SQL statement selects the first three records from the "Customers" table (for SQL Server/MS Access):
SELECT TOP 3 * FROM Customers;
The following SQL statement shows the equivalent example for MySQL:
The following SQL statement shows the equivalent example for Oracle:
The following SQL statement selects the first 50% of the records from the "Customers" table (for SQL Server/MS Access):
SELECT TOP 50 PERCENT * FROM Customers;
The following SQL statement shows the equivalent example for Oracle:
The following SQL statement selects the first three records from the "Customers" table, where the country is "Germany" (for SQL Server/MS Access):
The following SQL statement shows the equivalent example for MySQL:
the following SQL statement shows the equivalent example for Oracle:
The MIN() function returns the smallest value of the selected column.
The MAX() function returns the largest value of the selected column.
min syntax is following:
max syntax is following:
min syntax example:
MAX() Example:
The COUNT() function returns the number of rows that matches a specified criterion.
count syntax is following:
The AVG() function returns the average value of a numeric column and the syntax is following
The SUM() function returns the total sum of a numeric column and the syntax is following:
The following SQL statement finds the number of products:
Note: NULL values are not counted.
The following SQL statement finds the average price of all products:
Note: NULL values are ignored.
The following SQL statement finds the sum of the "Quantity" fields in the "OrderDetails" table:
The LIKE operator is used in a WHERE clause to search for a specified pattern in a column.
There are two wildcards often used in conjunction with the LIKE operator:
Note: MS Access uses an asterisk (*) instead of the percent sign (%), and a question mark (?) instead of the underscore (_).
The percent sign and the underscore can also be used in combinations! Like syntax is following:
Tip: You can also combine any number of conditions using AND or OR operators.
Here are some examples showing different LIKE operators with '%' and '_' wildcards:
The following SQL statement selects all customers with a CustomerName starting with "a":
The following SQL statement selects all customers with a CustomerName ending with "a":
The following SQL statement selects all customers with a CustomerName that have "or" in any position:
The following SQL statement selects all customers with a CustomerName that have "r" in the second position:
The following SQL statement selects all customers with a CustomerName that starts with "a" and are at least 3 characters in length:
he following SQL statement selects all customers with a ContactName that starts with "a" and ends with "o":
The following SQL statement selects all customers with a CustomerName that does NOT start with "a":
A wildcard character is used to substitute one or more characters in a string.
Wildcard characters are used with the LIKE operator. The LIKE operator is used in a WHERE clause to search for a specified pattern in a column.
Wildcard Characters in MS Access
All the wildcards can also be used in combinations!
Here are some examples showing different LIKE operators with '%' and '_' wildcards:
The following SQL statement selects all customers with a City starting with "ber":
The following SQL statement selects all customers with a City containing the pattern "es":
The following SQL statement selects all customers with a City starting with any character, followed by "ondon":
The following SQL statement selects all customers with a City starting with "L", followed by any character, followed by "n", followed by any character, followed by "on":
The following SQL statement selects all customers with a City starting with "b", "s", or "p":
The following SQL statement selects all customers with a City starting with "a", "b", or "c":
the two following SQL statements select all customers with a City NOT starting with "b", "s", or "p":
or
The IN operator allows you to specify multiple values in a WHERE clause.
The IN operator is a shorthand for multiple OR conditions.
IN Syntax is following:
or
The following SQL statement selects all customers that are located in "Germany", "France" or "UK":
The following SQL statement selects all customers that are NOT located in "Germany", "France" or "UK":
The following SQL statement selects all customers that are from the same countries as the suppliers:
The BETWEEN operator selects values within a given range. The values can be numbers, text, or dates.
The BETWEEN operator is inclusive: begin and end values are included.
BETWEEN syntax
The following SQL statement selects all products with a price between 10 and 20:
To display the products outside the range of the previous example, use NOT BETWEEN:
The following SQL statement selects all products with a price between 10 and 20. In addition; do not show products with a CategoryID of 1,2, or 3:
The following SQL statement selects all products with a ProductName between Carnarvon Tigers and Mozzarella di Giovanni:
The following SQL statement selects all products with a ProductName between Carnarvon Tigers and Chef Anton's Cajun Seasoning:
The following SQL statement selects all products with a ProductName not between Carnarvon Tigers and Mozzarella di Giovanni:
The following SQL statement selects all orders with an OrderDate between '01-July-1996' and '31-July-1996':
or
SQL aliases are used to give a table, or a column in a table, a temporary name.
Aliases are often used to make column names more readable.
An alias only exists for the duration of that query.
An alias is created with the AS keyword.
Alias Column Syntax
Alias Table Syntax
The following SQL statement creates two aliases, one for the CustomerID column and one for the CustomerName column:
The following SQL statement creates two aliases, one for the CustomerName column and one for the ContactName column. Note: It requires double quotation marks or square brackets if the alias name contains spaces:
The following SQL statement creates an alias named "Address" that combine four columns (Address, PostalCode, City and Country):
Note: To get the SQL statement above to work in MySQL use the following:
The following SQL statement selects all the orders from the customer with CustomerID=4 (Around the Horn).
We use the "Customers" and "Orders" tables, and give them the table aliases of "c" and "o" respectively (Here we use aliases to make the SQL shorter):
The following SQL statement is the same as above, but without aliases:
Aliases can be useful when:
A JOIN clause is used to combine rows from two or more tables, based on a related column between them.
we can create the following SQL statement (that contains an INNER JOIN), that selects records that have matching values in both tables:
Here are the different types of the JOINs in SQL:
The INNER JOIN keyword selects records that have matching values in both tables.
The following SQL statement selects all orders with customer information:
Note: The INNER JOIN keyword selects all rows from both tables as long as there is a match between the columns. If there are records in the "Orders" table that do not have matches in "Customers", these orders will not be shown!
The following SQL statement selects all orders with customer and shipper information:
The LEFT JOIN keyword returns all records from the left table (table1), and the matching records from the right table (table2). The result is 0 records from the right side, if there is no match.
Note: In some databases LEFT JOIN is called LEFT OUTER JOIN.
The following SQL statement will select all customers, and any orders they might have:
Note: The LEFT JOIN keyword returns all records from the left table (Customers), even if there are no matches in the right table (Orders).
The RIGHT JOIN keyword returns all records from the right table (table2), and the matching records from the left table (table1). The result is 0 records from the left side, if there is no match.
Note: In some databases RIGHT JOIN is called RIGHT OUTER JOIN.
The following SQL statement will return all employees, and any orders they might have placed:
Note: The RIGHT JOIN keyword returns all records from the right table (Employees), even if there are no matches in the left table (Orders).
The FULL OUTER JOIN keyword returns all records when there is a match in left (table1) or right (table2) table records.
Tip: FULL OUTER JOIN and FULL JOIN are the same.
Note: FULL OUTER JOIN can potentially return very large result-sets!
The following SQL statement selects all customers, and all orders:
Note: The FULL OUTER JOIN keyword returns all matching records from both tables whether the other table matches or not. So, if there are rows in "Customers" that do not have matches in "Orders", or if there are rows in "Orders" that do not have matches in "Customers", those rows will be listed as well.
A self join is a regular join, but the table is joined with itself.
T1 and T2 are different table aliases for the same table.
The following SQL statement matches customers that are from the same city:
this <> sign is - not equal to - sign
The UNION operator is used to combine the result-set of two or more SELECT statements.
union syntax is following:
The UNION operator selects only distinct values by default. To allow duplicate values, use UNION ALL:
Note: The column names in the result-set are usually equal to the column names in the first SELECT statement.
The following SQL statement returns the cities (only distinct values) from both the "Customers" and the "Suppliers" table:
Note: If some customers or suppliers have the same city, each city will only be listed once, because UNION selects only distinct values. Use UNION ALL to also select duplicate values!
The following SQL statement returns the cities (duplicate values also) from both the "Customers" and the "Suppliers" table:
The following SQL statement returns the German cities (only distinct values) from both the "Customers" and the "Suppliers" table:
The following SQL statement returns the German cities (duplicate values also) from both the "Customers" and the "Suppliers" table:
The following SQL statement lists all customers and suppliers:
Notice the "AS Type" above - it is an alias.  An alias only exists for the duration of the query. So, here we have created a temporary column named "Type", that list whether the contact person is a "Customer" or a "Supplier".
The GROUP BY statement groups rows that have the same values into summary rows, like "find the number of customers in each country".
The GROUP BY statement is often used with aggregate functions (COUNT(), MAX(), MIN(), SUM(), AVG()) to group the result-set by one or more columns.
The following SQL statement lists the number of customers in each country:
The following SQL statement lists the number of customers in each country, sorted high to low:
The following SQL statement lists the number of customers in each country, sorted low to high:
The following SQL statement lists the number of orders sent by each shipper:
The HAVING clause was added to SQL because the WHERE keyword cannot be used with aggregate functions.
The following SQL statement lists the number of customers in each country. Only include countries with more than 5 customers:
The following SQL statement lists the number of customers in each country, sorted high to low (Only include countries with more than 5 customers):
The following SQL statement lists the employees that have registered more than 10 orders:
The following SQL statement lists if the employees "Davolio" or "Fuller" have registered more than 25 orders:
The EXISTS operator is used to test for the existence of any record in a subquery.
The EXISTS operator returns TRUE if the subquery returns one or more records.
The following SQL statement returns TRUE and lists the suppliers with a product price less than 20:
The following SQL statement returns TRUE and lists the suppliers with a product price equal to 22:
The following SQL statement returns TRUE and lists the suppliers ContactName with a product price equal to 20:
The ANY and ALL operators allow you to perform a comparison between a single column value and a range of other values.
The ANY operator:
ANY means that the condition will be true if the operation is true for any of the values in the range.
The ALL operator:
ALL means that the condition will be true only if the operation is true for all values in the range.
The following SQL statement lists the ProductName if it finds ANY records in the OrderDetails table has Quantity equal to 10 (this will return TRUE because the Quantity column has some values of 10):
The following SQL statement lists the ProductName if it finds ANY records in the OrderDetails table has Quantity larger than 99 (this will return TRUE because the Quantity column has some values larger than 99):
The following SQL statement lists the ProductName if it finds ANY records in the OrderDetails table has Quantity larger than 1000 (this will return FALSE because the Quantity column has no values larger than 1000):
The following SQL statement lists ALL the product names:
The following SQL statement lists the ProductName if ALL the records in the OrderDetails table has Quantity equal to 10.
This will of course return FALSE because the Quantity column has many different values (not only the value of 10):
The SELECT INTO statement copies data from one table into a new table.
syntax of - Copy all columns into a new table:
Copy only some columns into a new table:
The new table will be created with the column-names and types as defined in the old table. You can create new column names using the AS clause.
The following SQL statement creates a backup copy of Customers:
The following SQL statement uses the IN clause to copy the table into a new table in another database:
The following SQL statement copies only a few columns into a new table:
The following SQL statement copies only the German customers into a new table:
The following SQL statement copies data from more than one table into a new table:
Tip: SELECT INTO can also be used to create a new, empty table using the schema of another. Just add a WHERE clause that causes the query to return no data:
The INSERT INTO SELECT statement copies data from one table and inserts it into another table.
The INSERT INTO SELECT statement requires that the data types in source and target tables matches.
Note: The existing records in the target table are unaffected.
Copy all columns from one table to another table:
Copy only some columns from one table into another table:
The following SQL statement copies "Suppliers" into "Customers" (the columns that are not filled with data, will contain NULL):
The following SQL statement copies "Suppliers" into "Customers" (fill all columns):
The following SQL statement copies only the German suppliers into "Customers":
The CASE statement goes through conditions and returns a value when the first condition is met (like an if-then-else statement).
So, once a condition is true, it will stop reading and return the result. If no conditions are true, it returns the value in the ELSE clause.
If there is no ELSE part and no conditions are true, it returns NULL.
The following SQL goes through conditions and returns a value when the first condition is met:
The following SQL will order the customers by City. However, if City is NULL, then order by Country:
Suppose that the "UnitsOnOrder" column is optional, and may contain NULL values.
Look at the following SELECT statement:
In the example above, if any of the "UnitsOnOrder" values are NULL, the result will be NULL.
The MySQL IFNULL() function lets you return an alternative value if an expression is NULL:
or we can use the COALESCE() function, like this:
The SQL Server ISNULL() function lets you return an alternative value when an expression is NULL:
The MS Access IsNull() function returns TRUE (-1) if the expression is a null value, otherwise FALSE (0):
The Oracle NVL() function achieves the same result:
What is a Stored Procedure?
A stored procedure is a prepared SQL code that you can save, so the code can be reused over and over again.
So if you have an SQL query that you write over and over again, save it as a stored procedure, and then just call it to execute it.
You can also pass parameters to a stored procedure, so that the stored procedure can act based on the parameter value(s) that is passed.
EXEC procedure_name;
The following SQL statement creates a stored procedure named "SelectAllCustomers" that selects all records from the "Customers" table:
Execute the stored procedure above as follows:
EXEC SelectAllCustomers;
The following SQL statement creates a stored procedure that selects Customers from a particular City from the "Customers" table:
Execute the stored procedure above as follows:
Setting up multiple parameters is very easy. Just list each parameter and the data type separated by a comma as shown below.
The following SQL statement creates a stored procedure that selects Customers from a particular City with a particular PostalCode from the "Customers" table:
Execute the stored procedure above as follows:
Comments are used to explain sections of SQL statements, or to prevent execution of SQL statements.
Comments are not supported in Microsoft Access databases. Firefox and Microsoft Edge are using Microsoft Access database in our examples.
Single line comments start with --.
Any text between -- and the end of the line will be ignored (will not be executed).
The following example uses a single-line comment as an explanation:
The following example uses a single-line comment to ignore the end of a line:
The following example uses a single-line comment to ignore a statement:
Multi-line comments start with /* and end with */.
Any text between /* and */ will be ignored.
The following example uses a multi-line comment as an explanation:
The following example uses a multi-line comment to ignore many statements:
To ignore just a part of a statement, also use the /* */ comment.
The following example uses a comment to ignore part of a line:
The following example uses a comment to ignore part of a statement:
The CREATE DATABASE statement is used to create a new SQL database.
Syntax is following:
The following SQL statement creates a database called "testDB":
CREATE DATABASE testDB;
Tip: Make sure you have admin privilege before creating any database. Once a database is created, you can check it in the list of databases with the following SQL command: SHOW DATABASES;
The DROP DATABASE statement is used to drop an existing SQL database. syntax is following: DROP DATABASE databasename;
Note: Be careful before dropping a database. Deleting a database will result in loss of complete information stored in the database!
The following SQL statement drops the existing database "testDB": DROP DATABASE testDB;
Tip: Make sure you have admin privilege before dropping any database. Once a database is dropped, you can check it in the list of databases with the following SQL command: SHOW DATABASES;
The BACKUP DATABASE statement is used in SQL Server to create a full back up of an existing SQL database.
syntax is following: BACKUP DATABASE databasename TO DISK = 'filepath';
A differential back up only backs up the parts of the database that have changed since the last full database backup. syntax is following: BACKUP DATABASE databasename TO DISK = 'filepath' WITH DIFFERENTIAL;
The following SQL statement creates a full back up of the existing database "testDB" to the D disk: example: BACKUP DATABASE testDB TO DISK = 'D:\backups\testDB.bak';
Tip: Always back up the database to a different drive than the actual database. Then, if you get a disk crash, you will not lose your backup file along with the database.
The following SQL statement creates a differential back up of the database "testDB": example BACKUP DATABASE testDB TO DISK = 'D:\backups\testDB.bak' WITH DIFFERENTIAL;
Tip: A differential back up reduces the back up time (since only the changes are backed up).
The CREATE TABLE statement is used to create a new table in a database. syntax is following: CREATE TABLE table_name ( column1 datatype, column2 datatype, column3 datatype, .... ); The column parameters specify the names of the columns of the table. The datatype parameter specifies the type of data the column can hold (e.g. varchar, integer, date, etc.).
The following example creates a table called "Persons" that contains five columns: PersonID, LastName, FirstName, Address, and City: CREATE TABLE Persons ( PersonID int, LastName varchar(255), FirstName varchar(255), Address varchar(255), City varchar(255) ); The PersonID column is of type int and will hold an integer. The LastName, FirstName, Address, and City columns are of type varchar and will hold characters, and the maximum length for these fields is 255 characters. Tip: The empty "Persons" table can now be filled with data with the SQL INSERT INTO statement.
A copy of an existing table can also be created using CREATE TABLE. The new table gets the same column definitions. All columns or specific columns can be selected. If you create a new table using an existing table, the new table will be filled with the existing values from the old table. syntax is following: CREATE TABLE new_table_name AS SELECT column1, column2,... FROM existing_table_name WHERE ....;
The following SQL creates a new table called "TestTables" (which is a copy of the "Customers" table): CREATE TABLE TestTable AS SELECT customername, contactname FROM customers;
The DROP TABLE statement is used to drop an existing table in a database. Syntax is following: DROP TABLE table_name;
Note: Be careful before dropping a table. Deleting a table will result in loss of complete information stored in the table!
The following SQL statement drops the existing table "Shippers": DROP TABLE Shippers;
The TRUNCATE TABLE statement is used to delete the data inside a table, but not the table itself. syntax is following: TRUNCATE TABLE table_name;
The ALTER TABLE statement is used to add, delete, or modify columns in an existing table. The ALTER TABLE statement is also used to add and drop various constraints on an existing table. To add a column in a table, use the following syntax: ALTER TABLE table_name ADD column_name datatype;
The following SQL adds an "Email" column to the "Customers" table: ALTER TABLE Customers ADD Email varchar(255);
To delete a column in a table, use the following syntax (notice that some database systems don't allow deleting a column): ALTER TABLE table_name DROP COLUMN column_name;
The following SQL deletes the "Email" column from the "Customers" table: ALTER TABLE Customers DROP COLUMN Email;
To change the data type of a column in a table, use the following syntax: SQL Server / MS Access: ALTER TABLE table_name ALTER COLUMN column_name datatype; My SQL / Oracle (prior version 10G): ALTER TABLE table_name MODIFY COLUMN column_name datatype; Oracle 10G and later: ALTER TABLE table_name MODIFY column_name datatype;
SQL constraints are used to specify rules for data in a table. Constraints can be specified when the table is created with the CREATE TABLE statement, or after the table is created with the ALTER TABLE statement. syntax is following: CREATE TABLE table_name ( column1 datatype constraint, column2 datatype constraint, column3 datatype constraint, .... );
SQL constraints are used to specify rules for the data in a table. Constraints are used to limit the type of data that can go into a table. This ensures the accuracy and reliability of the data in the table. If there is any violation between the constraint and the data action, the action is aborted. Constraints can be column level or table level. Column level constraints apply to a column, and table level constraints apply to the whole table.
The following constraints are commonly used in SQL:
SQL NOT NULL Constraint By default, a column can hold NULL values. The NOT NULL constraint enforces a column to NOT accept NULL values. This enforces a field to always contain a value, which means that you cannot insert a new record, or update a record without adding a value to this field.
The following SQL ensures that the "ID", "LastName", and "FirstName" columns will NOT accept NULL values when the "Persons" table is created:
CREATE TABLE Persons ( ID int NOT NULL, LastName varchar(255) NOT NULL, FirstName varchar(255) NOT NULL, Age int );
To create a NOT NULL constraint on the "Age" column when the "Persons" table is already created, use the following SQL:
ALTER TABLE Persons MODIFY Age int NOT NULL;
The UNIQUE constraint ensures that all values in a column are different. Both the UNIQUE and PRIMARY KEY constraints provide a guarantee for uniqueness for a column or set of columns. A PRIMARY KEY constraint automatically has a UNIQUE constraint. However, you can have many UNIQUE constraints per table, but only one PRIMARY KEY constraint per table.
The following SQL creates a UNIQUE constraint on the "ID" column when the "Persons" table is created: SQL Server / Oracle / MS Access:
CREATE TABLE Persons ( ID int NOT NULL UNIQUE, LastName varchar(255) NOT NULL, FirstName varchar(255), Age int );
MySQL: CREATE TABLE Persons ( ID int NOT NULL, LastName varchar(255) NOT NULL, FirstName varchar(255), Age int, UNIQUE (ID) );
To name a UNIQUE constraint, and to define a UNIQUE constraint on multiple columns, use the following SQL syntax: MySQL / SQL Server / Oracle / MS Access: CREATE TABLE Persons ( ID int NOT NULL, LastName varchar(255) NOT NULL, FirstName varchar(255), Age int, CONSTRAINT UC_Person UNIQUE (ID,LastName) );
To create a UNIQUE constraint on the "ID" column when the table is already created, use the following SQL: MySQL / SQL Server / Oracle / MS Access: ALTER TABLE Persons ADD UNIQUE (ID);
To name a UNIQUE constraint, and to define a UNIQUE constraint on multiple columns, use the following SQL syntax: MySQL / SQL Server / Oracle / MS Access: ALTER TABLE Persons ADD CONSTRAINT UC_Person UNIQUE (ID,LastName);
To drop a UNIQUE constraint, use the following SQL: MySQL: ALTER TABLE Persons DROP INDEX UC_Person;
SQL Server / Oracle / MS Access: ALTER TABLE Persons DROP CONSTRAINT UC_Person;
The PRIMARY KEY constraint uniquely identifies each record in a table. Primary keys must contain UNIQUE values, and cannot contain NULL values. A table can have only ONE primary key; and in the table, this primary key can consist of single or multiple columns (fields).
The following SQL creates a PRIMARY KEY on the "ID" column when the "Persons" table is created: MySQL: CREATE TABLE Persons ( ID int NOT NULL, LastName varchar(255) NOT NULL, FirstName varchar(255), Age int, PRIMARY KEY (ID) ); SQL Server / Oracle / MS Access: CREATE TABLE Persons ( ID int NOT NULL PRIMARY KEY, LastName varchar(255) NOT NULL, FirstName varchar(255), Age int ); To allow naming of a PRIMARY KEY constraint, and for defining a PRIMARY KEY constraint on multiple columns, use the following SQL syntax: MySQL / SQL Server / Oracle / MS Access: CREATE TABLE Persons ( ID int NOT NULL, LastName varchar(255) NOT NULL, FirstName varchar(255), Age int, CONSTRAINT PK_Person PRIMARY KEY (ID,LastName) );
Note: In the example above there is only ONE PRIMARY KEY (PK_Person). However, the VALUE of the primary key is made up of TWO COLUMNS (ID + LastName).
MySQL / SQL Server / Oracle / MS Access: ALTER TABLE Persons ADD PRIMARY KEY (ID); To allow naming of a PRIMARY KEY constraint, and for defining a PRIMARY KEY constraint on multiple columns, use the following SQL syntax:
MySQL / SQL Server / Oracle / MS Access: ALTER TABLE Persons ADD CONSTRAINT PK_Person PRIMARY KEY (ID,LastName);
Note: If you use ALTER TABLE to add a primary key, the primary key column(s) must have been declared to not contain NULL values (when the table was first created).
To drop a PRIMARY KEY constraint, use the following SQL: MySQL: ALTER TABLE Persons DROP PRIMARY KEY; SQL Server / Oracle / MS Access: ALTER TABLE Persons DROP CONSTRAINT PK_Person;
The FOREIGN KEY constraint is used to prevent actions that would destroy links between tables. A FOREIGN KEY is a field (or collection of fields) in one table, that refers to the PRIMARY KEY in another table. The table with the foreign key is called the child table, and the table with the primary key is called the referenced or parent table. The "PersonID" column in the "Persons" table is the PRIMARY KEY in the "Persons" table. The "PersonID" column in the "Orders" table is a FOREIGN KEY in the "Orders" table. The FOREIGN KEY constraint prevents invalid data from being inserted into the foreign key column, because it has to be one of the values contained in the parent table.
The following SQL creates a FOREIGN KEY on the "PersonID" column when the "Orders" table is created: MySQL: CREATE TABLE Orders ( OrderID int NOT NULL, OrderNumber int NOT NULL, PersonID int, PRIMARY KEY (OrderID), FOREIGN KEY (PersonID) REFERENCES Persons(PersonID) );
SQL Server / Oracle / MS Access: CREATE TABLE Orders ( OrderID int NOT NULL PRIMARY KEY, OrderNumber int NOT NULL, PersonID int FOREIGN KEY REFERENCES Persons(PersonID) );
To allow naming of a FOREIGN KEY constraint, and for defining a FOREIGN KEY constraint on multiple columns, use the following SQL syntax: MySQL / SQL Server / Oracle / MS Access: CREATE TABLE Orders ( OrderID int NOT NULL, OrderNumber int NOT NULL, PersonID int, PRIMARY KEY (OrderID), CONSTRAINT FK_PersonOrder FOREIGN KEY (PersonID) REFERENCES Persons(PersonID) );
To create a FOREIGN KEY constraint on the "PersonID" column when the "Orders" table is already created, use the following SQL: MySQL / SQL Server / Oracle / MS Access: ALTER TABLE Orders ADD FOREIGN KEY (PersonID) REFERENCES Persons(PersonID); To allow naming of a FOREIGN KEY constraint, and for defining a FOREIGN KEY constraint on multiple columns, use the following SQL syntax: MySQL / SQL Server / Oracle / MS Access: ALTER TABLE Orders ADD CONSTRAINT FK_PersonOrder FOREIGN KEY (PersonID) REFERENCES Persons(PersonID);
To drop a FOREIGN KEY constraint, use the following SQL: MySQL: ALTER TABLE Orders DROP FOREIGN KEY FK_PersonOrder; SQL Server / Oracle / MS Access: ALTER TABLE Orders DROP CONSTRAINT FK_PersonOrder;
The CHECK constraint is used to limit the value range that can be placed in a column. If you define a CHECK constraint on a column it will allow only certain values for this column. If you define a CHECK constraint on a table it can limit the values in certain columns based on values in other columns in the row.
The following SQL creates a CHECK constraint on the "Age" column when the "Persons" table is created. The CHECK constraint ensures that the age of a person must be 18, or older: MySQL: CREATE TABLE Persons ( ID int NOT NULL, LastName varchar(255) NOT NULL, FirstName varchar(255), Age int, CHECK (Age>=18) ); SQL Server / Oracle / MS Access: CREATE TABLE Persons ( ID int NOT NULL, LastName varchar(255) NOT NULL, FirstName varchar(255), Age int CHECK (Age>=18) ); To allow naming of a CHECK constraint, and for defining a CHECK constraint on multiple columns, use the following SQL syntax: MySQL / SQL Server / Oracle / MS Access: CREATE TABLE Persons ( ID int NOT NULL, LastName varchar(255) NOT NULL, FirstName varchar(255), Age int, City varchar(255), CONSTRAINT CHK_Person CHECK (Age>=18 AND City='Sandnes') );
To create a CHECK constraint on the "Age" column when the table is already created, use the following SQL: MySQL / SQL Server / Oracle / MS Access: ALTER TABLE Persons ADD CHECK (Age>=18); To allow naming of a CHECK constraint, and for defining a CHECK constraint on multiple columns, use the following SQL syntax: MySQL / SQL Server / Oracle / MS Access: ALTER TABLE Persons ADD CONSTRAINT CHK_PersonAge CHECK (Age>=18 AND City='Sandnes');
To drop a CHECK constraint, use the following SQL: SQL Server / Oracle / MS Access: ALTER TABLE Persons DROP CONSTRAINT CHK_PersonAge; MySQL: ALTER TABLE Persons DROP CHECK CHK_PersonAge;
The DEFAULT constraint is used to set a default value for a column. The default value will be added to all new records, if no other value is specified.
The following SQL sets a DEFAULT value for the "City" column when the "Persons" table is created: My SQL / SQL Server / Oracle / MS Access: CREATE TABLE Persons ( ID int NOT NULL, LastName varchar(255) NOT NULL, FirstName varchar(255), Age int, City varchar(255) DEFAULT 'Sandnes' );
The DEFAULT constraint can also be used to insert system values, by using functions like GETDATE(): CREATE TABLE Orders ( ID int NOT NULL, OrderNumber int NOT NULL, OrderDate date DEFAULT GETDATE() );
To create a DEFAULT constraint on the "City" column when the table is already created, use the following SQL: MySQL: ALTER TABLE Persons ALTER City SET DEFAULT 'Sandnes'; SQL Server: ALTER TABLE Persons ADD CONSTRAINT df_City DEFAULT 'Sandnes' FOR City; MS Access: ALTER TABLE Persons ALTER COLUMN City SET DEFAULT 'Sandnes'; Oracle: ALTER TABLE Persons MODIFY City DEFAULT 'Sandnes';
To drop a DEFAULT constraint, use the following SQL: MySQL: ALTER TABLE Persons ALTER City DROP DEFAULT; SQL Server / Oracle / MS Access: ALTER TABLE Persons ALTER COLUMN City DROP DEFAULT;
The CREATE INDEX statement is used to create indexes in tables. Indexes are used to retrieve data from the database more quickly than otherwise. The users cannot see the indexes, they are just used to speed up searches/queries.
Note: Updating a table with indexes takes more time than updating a table without (because the indexes also need an update). So, only create indexes on columns that will be frequently searched against.
create index - Creates an index on a table. Duplicate values are allowed: CREATE INDEX index_name ON table_name (column1, column2, ...);
Creates a unique index on a table. Duplicate values are not allowed: CREATE UNIQUE INDEX index_name ON table_name (column1, column2, ...);
Note: The syntax for creating indexes varies among different databases. Therefore: Check the syntax for creating indexes in your database.The SQL statement below creates an index named "idx_lastname" on the "LastName" column in the "Persons" table: CREATE INDEX idx_lastname ON Persons (LastName); If you want to create an index on a combination of columns, you can list the column names within the parentheses, separated by commas: CREATE INDEX idx_pname ON Persons (LastName, FirstName);
The DROP INDEX statement is used to delete an index in a table. MS Access: DROP INDEX index_name ON table_name; SQL Server: DROP INDEX table_name.index_name; DB2/Oracle: DROP INDEX index_name; MySQL: ALTER TABLE table_name DROP INDEX index_name;
Auto-increment allows a unique number to be generated automatically when a new record is inserted into a table. Often this is the primary key field that we would like to be created automatically every time a new record is inserted.
The following SQL statement defines the "Personid" column to be an auto-increment primary key field in the "Persons" table: CREATE TABLE Persons ( Personid int NOT NULL AUTO_INCREMENT, LastName varchar(255) NOT NULL, FirstName varchar(255), Age int, PRIMARY KEY (Personid) ); MySQL uses the AUTO_INCREMENT keyword to perform an auto-increment feature. By default, the starting value for AUTO_INCREMENT is 1, and it will increment by 1 for each new record. To let the AUTO_INCREMENT sequence start with another value, use the following SQL statement: ALTER TABLE Persons AUTO_INCREMENT=100; To insert a new record into the "Persons" table, we will NOT have to specify a value for the "Personid" column (a unique value will be added automatically):
The SQL statement above would insert a new record into the "Persons" table. The "Personid" column would be assigned a unique value. The "FirstName" column would be set to "Lars" and the "LastName" column would be set to "Monsen".
The following SQL statement defines the "Personid" column to be an auto-increment primary key field in the "Persons" table: CREATE TABLE Persons ( Personid int IDENTITY(1,1) PRIMARY KEY, LastName varchar(255) NOT NULL, FirstName varchar(255), Age int ); The MS SQL Server uses the IDENTITY keyword to perform an auto-increment feature. In the example above, the starting value for IDENTITY is 1, and it will increment by 1 for each new record. Tip: To specify that the "Personid" column should start at value 10 and increment by 5, change it to IDENTITY(10,5).
To insert a new record into the "Persons" table, we will NOT have to specify a value for the "Personid" column (a unique value will be added automatically):
The SQL statement above would insert a new record into the "Persons" table. The "Personid" column would be assigned a unique value. The "FirstName" column would be set to "Lars" and the "LastName" column would be set to "Monsen".
The following SQL statement defines the "Personid" column to be an auto-increment primary key field in the "Persons" table:
CREATE TABLE Persons ( Personid AUTOINCREMENT PRIMARY KEY, LastName varchar(255) NOT NULL, FirstName varchar(255), Age int ); The MS Access uses the AUTOINCREMENT keyword to perform an auto-increment feature. By default, the starting value for AUTOINCREMENT is 1, and it will increment by 1 for each new record. Tip: To specify that the "Personid" column should start at value 10 and increment by 5, change the autoincrement to AUTOINCREMENT(10,5). To insert a new record into the "Persons" table, we will NOT have to specify a value for the "Personid" column (a unique value will be added automatically):
The SQL statement above would insert a new record into the "Persons" table. The "Personid" column would be assigned a unique value. The "FirstName" column would be set to "Lars" and the "LastName" column would be set to "Monsen".
In Oracle the code is a little bit more tricky. You will have to create an auto-increment field with the sequence object (this object generates a number sequence). Use the following CREATE SEQUENCE syntax:
The code above creates a sequence object called seq_person, that starts with 1 and will increment by 1. It will also cache up to 10 values for performance. The cache option specifies how many sequence values will be stored in memory for faster access. To insert a new record into the "Persons" table, we will have to use the nextval function (this function retrieves the next value from seq_person sequence):
The most difficult part when working with dates is to be sure that the format of the date you are trying to insert, matches the format of the date column in the database. As long as your data contains only the date portion, your queries will work as expected. However, if a time portion is involved, it gets more complicated.
MySQL comes with the following data types for storing a date or a date/time value in the database:
SQL Server comes with the following data types for storing a date or a date/time value in the database:
SELECT * FROM Orders WHERE OrderDate='2008-11-11' Tip: To keep your queries simple and easy to maintain, do not use time-components in your dates, unless you have to!
In SQL, a view is a virtual table based on the result-set of an SQL statement. A view contains rows and columns, just like a real table. The fields in a view are fields from one or more real tables in the database. You can add SQL statements and functions to a view and present the data as if the data were coming from one single table. A view is created with the CREATE VIEW statement.
Note: A view always shows up-to-date data! The database engine recreates the view, every time a user queries it.
The following SQL creates a view that shows all customers from Brazil:
CREATE VIEW [Brazil Customers] AS SELECT CustomerName, ContactName FROM Customers WHERE Country = 'Brazil';
We can query the view above as follows: SELECT * FROM [Brazil Customers];
The following SQL creates a view that selects every product in the "Products" table with a price higher than the average price:
We can query the view above as follows: SELECT * FROM [Products Above Average Price];
A view can be updated with the CREATE OR REPLACE VIEW statement.
The following SQL adds the "City" column to the "Brazil Customers" view: CREATE OR REPLACE VIEW [Brazil Customers] AS SELECT CustomerName, ContactName, City FROM Customers WHERE Country = 'Brazil';
A view is deleted with the DROP VIEW statement. syntax is following: DROP VIEW view_name;
The following SQL drops the "Brazil Customers" view: DROP VIEW [Brazil Customers];
SQL injection is a code injection technique that might destroy your database. SQL injection is one of the most common web hacking techniques. SQL injection is the placement of malicious code in SQL statements, via web page input.
SQL injection usually occurs when you ask a user for input, like their username/userid, and instead of a name/id, the user gives you an SQL statement that you will unknowingly run on your database. Look at the following example which creates a SELECT statement by adding a variable (txtUserId) to a select string. The variable is fetched from user input (getRequestString): txtUserId = getRequestString("UserId"); txtSQL = "SELECT * FROM Users WHERE UserId = " + txtUserId;
The rest of this chapter describes the potential dangers of using user input in SQL statements.
Look at the example above again. The original purpose of the code was to create an SQL statement to select a user, with a given user id. If there is nothing to prevent a user from entering "wrong" input, the user can enter some "smart" input like this: UserId: 105 OR 1=1 Then, the SQL statement will look like this: SELECT * FROM Users WHERE UserId = 105 OR 1=1;
The SQL above is valid and will return ALL rows from the "Users" table, since OR 1=1 is always TRUE. Does the example above look dangerous? What if the "Users" table contains names and passwords? The SQL statement above is much the same as this: SELECT UserId, Name, Password FROM Users WHERE UserId = 105 or 1=1; A hacker might get access to all the user names and passwords in a database, by simply inserting 105 OR 1=1 into the input field.
Here is an example of a user login on a web site:
example: uName = getRequestString("username"); uPass = getRequestString("userpassword"); sql = 'SELECT * FROM Users WHERE Name ="' + uName + '" AND Pass ="' + uPass + '"' Result: SELECT * FROM Users WHERE Name ="John Doe" AND Pass ="myPass"
A hacker might get access to user names and passwords in a database by simply inserting " OR ""=" into the user name or password text box:
The SQL above is valid and will return all rows from the "Users" table, since OR ""="" is always TRUE.
Most databases support batched SQL statement. A batch of SQL statements is a group of two or more SQL statements, separated by semicolons. The SQL statement below will return all rows from the "Users" table, then delete the "Suppliers" table. Example SELECT * FROM Users; DROP TABLE Suppliers
Look at the following example: txtUserId = getRequestString("UserId"); txtSQL = "SELECT * FROM Users WHERE UserId = " + txtUserId; And the following input: User id: 105; DROP TABLE Suppliers The valid SQL statement would look like this: Result: SELECT * FROM Users WHERE UserId = 105; DROP TABLE Suppliers;
To protect a web site from SQL injection, you can use SQL parameters. SQL parameters are values that are added to an SQL query at execution time, in a controlled manner.
txtUserId = getRequestString("UserId"); txtSQL = "SELECT * FROM Users WHERE UserId = @0"; db.Execute(txtSQL,txtUserId);
Note that parameters are represented in the SQL statement by a @ marker. The SQL engine checks each parameter to ensure that it is correct for its column and are treated literally, and not as part of the SQL to be executed.
txtNam = getRequestString("CustomerName"); txtAdd = getRequestString("Address"); txtCit = getRequestString("City"); txtSQL = "INSERT INTO Customers (CustomerName,Address,City) Values(@0,@1,@2)"; db.Execute(txtSQL,txtNam,txtAdd,txtCit);
The following examples shows how to build parameterized queries in some common web languages.
SELECT STATEMENT IN ASP.NET:
txtUserId = getRequestString("UserId"); sql = "SELECT * FROM Customers WHERE CustomerId = @0"; command = new SqlCommand(sql); command.Parameters.AddWithValue("@0",txtUserId); command.ExecuteReader();
INSERT INTO STATEMENT IN ASP.NET:
txtNam = getRequestString("CustomerName"); txtAdd = getRequestString("Address"); txtCit = getRequestString("City"); txtSQL = "INSERT INTO Customers (CustomerName,Address,City) Values(@0,@1,@2)"; command = new SqlCommand(txtSQL); command.Parameters.AddWithValue("@0",txtNam); command.Parameters.AddWithValue("@1",txtAdd); command.Parameters.AddWithValue("@2",txtCit); command.ExecuteNonQuery();
INSERT INTO STATEMENT IN PHP:
$stmt = $dbh->prepare("INSERT INTO Customers (CustomerName,Address,City) VALUES (:nam, :add, :cit)"); $stmt->bindParam(':nam', $txtNam); $stmt->bindParam(':add', $txtAdd); $stmt->bindParam(':cit', $txtCit); $stmt->execute();
If you want your web site to be able to store and retrieve data from a database, your web server should have access to a database-system that uses the SQL language. If your web server is hosted by an Internet Service Provider (ISP), you will have to look for SQL hosting plans. The most common SQL hosting databases are MS SQL Server, Oracle, MySQL, and MS Access.
Microsoft's SQL Server is a popular database software for database-driven web sites with high traffic. SQL Server is a very powerful, robust and full featured SQL database system.
Oracle is also a popular database software for database-driven web sites with high traffic. Oracle is a very powerful, robust and full featured SQL database system.
MySQL is also a popular database software for web sites. MySQL is a very powerful, robust and full featured SQL database system. MySQL is an inexpensive alternative to the expensive Microsoft and Oracle solutions.
When a web site requires only a simple database, Microsoft Access can be a solution. MS Access is not well suited for very high-traffic, and not as powerful as MySQL, SQL Server, or Oracle.
The data type of a column defines what value the column can hold: integer, character, money, date and time, binary, and so on. Each column in a database table is required to have a name and a data type. An SQL developer must decide what type of data that will be stored inside each column when creating a table. The data type is a guideline for SQL to understand what type of data is expected inside of each column, and it also identifies how SQL will interact with the stored data. Note: Data types might have different names in different database. And even if the name is the same, the size and other details may be different! Always check the documentation!


Kanye West addresses Joel Osteen's church: I'm 'in service to God'
by Sasha SavitskyKanye West addressed parishioners at Joel Osteen’s Houston megachurch on Sunday where he said his recent spiritual awakening has made him realize he’s no longer in the service of fame and money but “in service to God.”
West spoke to a crowd of around 16,000 people at Lakewood Church’s 11 a.m. service.
During a 20-minute interview with Osteen before about 16,000 Lakewood Church parishioners, West told the packed crowd about his recent conversion to Christianity and how God has been inspiring him.
KANYE WEST PERFORMS AT HOUSTON JAIL
“I know that God has been calling me for a long time and the devil has been distracting me for a long time,” West said as he stood next to Osteen.
The rapper shared that at his lowest point, when he was hospitalized in 2016 after a “mental breakdown,” God “was there with me, sending me visions, inspiring me.”
Last month, West released “Jesus is King,” a Gospel-themed album that’s been described as Christian rap.
West also was scheduled to perform Sunday evening at Lakewood with his “Sunday Service,” a church-like concert featuring a choir. Tickets for the free concert were distributed through Ticketmaster and sold out within minutes on Saturday, though some people have been reselling them for hundreds of dollars.
KANYE WEST’S SUNDAY SERVICE HAD ‘OVER 1,000’ COMMIT THEIR LIVES TO CHRIST: ‘NEW WAVE OF REVIVAL’
West has been traveling around the U.S. holding his “Sunday Service” concerts since January, including at the Coachella festival, an outdoor shopping center in Salt Lake City and at an Atlanta-area megachurch.
On Friday, he and his choir performed for inmates at the Harris County Jail in Houston.
During Sunday’s appearance, West touched on a variety of topics, including religion, the perils of fame and money and going to church as a child. He also talked about how he used to approach things, telling parishioners that “all of that arrogance” that people had seen in him, he is “now using it for God.”
“The only superstar is Jesus,” West said as the crowd applauded loudly.
WHO IS KANYE'S PASTOR PREACHING AT SUNDAY SERVICE?
Lakewood Church, where more than 43,000 people attend services each week, has become the largest church in the U.S. It holds services at the former Compaq Center, which was once the home of the Houston Rockets.
Osteen’s weekly television program is viewed by more than 13 million households in the U.S. and millions more in more than 100 nations around the world.
The Associated Press contributed to this report.


FlyOde
Home
About
Overview
Quick Guide
Description
Outlook
About Us
Funding & Legal Notice
FAQ
Name *
E-mail *
I don't want my name to be published on the FlyOde website or anywhere else.
Node:
Organ
Subnetwork
Node symbol/name
Fly base link
Phenotypes
References
Expression Pattern
Interaction:
Source
Target
Interaction
References
Source
Target
Interaction
References
Source
Target
Interaction
References
Comments/Remarks
Submit
* required