1. Technology
Send to a Friend via Email
You can opt-out at any time. Please refer to our privacy policy for contact information.

Discuss in my forum

Structured Query Language Frequently Asked Questions

By

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!

1. How can I retrieve data from a database using SQL?

Young woman concentrated on her work
alvarez/Vetta/Getty Images
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.

2. How do I create a new database or a new database table?

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.

3. How do I add data to a database?

The INSERT command in SQL is used to add records to an existing table.

4. How do I delete some or all of a database 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.

5. What is a NULL value?

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.)

6. How can I combine data from multiple database tables?

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.

7. Can I join a table to itself?

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.

8. How can I summarize data contained within a database 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.

9. How can I group summarized data?

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.

10. How can I restrict access to data contained within an SQL database?

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.
  1. About.com
  2. Technology
  3. Databases
  4. Learning SQL
  5. Structured Query Language (SQL) Frequently Asked Questions

©2014 About.com. All rights reserved.