Looking for advice on using the Structured Query Language? The About Databases SQL FAQ provides answers to the most frequently asked questions about SQL and databases. Be sure to follow the "More Info" links at the end of each question for detailed explanations and tutorials!
The SELECT command is the most commonly used command in SQL. It allows database users to retrieve the specific information they desire from an operational database.
SQL provides the CREATE DATABASE and CREATE TABLE commands to add new databases and tables, respectively to your database. These commands provide a highly flexible syntax allowing you to create tables and databases that meet your specific business requirements.
The INSERT command in SQL is used to add records to an existing table.
Oftentimes, it becomes necessary to remove obsolete information from a relational database. Fortunately, Structured Query Language provides a flexible DELETE command that can be used to remove some or all of the information stored within a table.
NULL is the value used to represent an unknown piece of data. Databases treat NULL values in a special way, depending upon the type of operation that it is used in. When a NULL value appears as an operand to an AND operation, the operation’s value is FALSE if the other operand is FALSE (there is no way the expression could be TRUE with one FALSE operand). On the other hand, the result is NULL (unknown) if the other operand is either TRUE or NULL (because we can’t tell what the result would be.)
SQL join statements allow you to combine data from two or more tables in your query results. Learn how to leverage this powerful technology to supercharge your database queries.
Yes! You can use a self-join to simplify nested SQL queries where the inner and outer queries reference the same table. These joins allow you to retrieve related records from the same table.
SQL provides aggregate functions to assist with the summarization of large volumes of data. The SUM function is used within a SELECT statement and returns the total of a series of values. The AVG function works in a similar manner to provide the mathematical average of a series of values. SQL provides the COUNT function to retrieve the number of records in a table that meet given criteria. The MAX() function returns the largest value in a given data series while the MIN() function returns the smallest value.
You may use basic SQL queries to retrieve data from a database but this often doesn’t provide enough intelligence to meet business requirements. SQL also provides you with the ability to group query results based upon row-level attributes in order to apply aggregate functions using the GROUP BY clause.
SQL databases provide administrators with a role-based access control system. In this schema, administrators create user accounts for each individual database user and then assign that user to one or more database roles that describe a way the user is allowed to interact with the database. Finally, the administrator grants specific permissions to the role to allow role members to carry out the desired actions. Users are implicitly denied any access that they are not explicitly granted.