Beginning SQL

Beginning SQL Beginning SQL

marjan.fesb.hr
from marjan.fesb.hr More from this publisher
20.07.2013 Views

Databases are great at dealing with large amounts of data that need to be searched, sorted, or regularly updated. As you find out in the next few chapters, databases combined with SQL allow you to get the answers you want in the order you want. Database Management Systems Used in This Book Databases are great for storing data, the database management system provides ways of looking at the data, and usually software provided allows you to view the data. But how do you use the data outside of the database management software? The operating system, whether it’s Windows, UNIX, Linux, or the Macintosh, provides ways of hooking into the database management system and extracting the data. You need to write programming code to put inside a stand-alone application that the user runs on their computer, or you could set up a Web page to extract data. You’re not restricted to certain languages, so long as the language allows you to hook into the database management software. You can buy any number of different relational database management systems off the shelf, but this book’s aim is to present SQL that is standards compliant (more on the standards in the next section) and that works with as wide a range of RDBMSs as possible. However, there are times when the standards don’t allow you to do what you want. Other times, you may find that the various DBMS vendors haven’t implemented them consistently. This book provides details specific to MS Access, MS SQL Server 2000, IBM DB2, MySQL, and Oracle 10. Structured Query Language (SQL) The first questions to ask are what is SQL and how do you use it with databases? SQL has three main roles: ❑ Creating a database and defining its structure ❑ Querying the database to obtain the data necessary to answer questions ❑ Controlling database security Defining database structure includes creating new database tables and fields, setting up rules for data entry, and so on, which is expressed by a SQL sublanguage called Data Control Language (DCL), covered later in this chapter. The next section discusses querying the database. Finally, DCL deals with database security. Generally, database security is something that database administrators handle. Creating SQL every time you want to change the database structure or security sounds like hard work, and it is! Most modern database systems allow you to execute changes via a user-friendly interface without a single line of SQL. Introducing SQL Queries Introduction to SQL SQL queries are the most common use of SQL. A SQL sublanguage called Data Manipulation Language (DML) deals with queries and data manipulation. SQL allows you to pose a query (basically a question) 11

Databases are great at dealing with large amounts of data that need to be searched, sorted, or regularly<br />

updated. As you find out in the next few chapters, databases combined with <strong>SQL</strong> allow you to get the<br />

answers you want in the order you want.<br />

Database Management Systems Used in This Book<br />

Databases are great for storing data, the database management system provides ways of looking at the<br />

data, and usually software provided allows you to view the data. But how do you use the data outside<br />

of the database management software? The operating system, whether it’s Windows, UNIX, Linux, or<br />

the Macintosh, provides ways of hooking into the database management system and extracting the data.<br />

You need to write programming code to put inside a stand-alone application that the user runs on their<br />

computer, or you could set up a Web page to extract data. You’re not restricted to certain languages, so<br />

long as the language allows you to hook into the database management software.<br />

You can buy any number of different relational database management systems off the shelf, but this<br />

book’s aim is to present <strong>SQL</strong> that is standards compliant (more on the standards in the next section) and<br />

that works with as wide a range of RDBMSs as possible. However, there are times when the standards<br />

don’t allow you to do what you want. Other times, you may find that the various DBMS vendors<br />

haven’t implemented them consistently. This book provides details specific to MS Access, MS <strong>SQL</strong><br />

Server 2000, IBM DB2, My<strong>SQL</strong>, and Oracle 10.<br />

Structured Query Language (<strong>SQL</strong>)<br />

The first questions to ask are what is <strong>SQL</strong> and how do you use it with databases? <strong>SQL</strong> has three<br />

main roles:<br />

❑ Creating a database and defining its structure<br />

❑ Querying the database to obtain the data necessary to answer questions<br />

❑ Controlling database security<br />

Defining database structure includes creating new database tables and fields, setting up rules for data<br />

entry, and so on, which is expressed by a <strong>SQL</strong> sublanguage called Data Control Language (DCL),<br />

covered later in this chapter. The next section discusses querying the database.<br />

Finally, DCL deals with database security. Generally, database security is something that database<br />

administrators handle.<br />

Creating <strong>SQL</strong> every time you want to change the database structure or security sounds like hard work,<br />

and it is! Most modern database systems allow you to execute changes via a user-friendly interface<br />

without a single line of <strong>SQL</strong>.<br />

Introducing <strong>SQL</strong> Queries<br />

Introduction to <strong>SQL</strong><br />

<strong>SQL</strong> queries are the most common use of <strong>SQL</strong>. A <strong>SQL</strong> sublanguage called Data Manipulation Language<br />

(DML) deals with queries and data manipulation. <strong>SQL</strong> allows you to pose a query (basically a question)<br />

11

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!