Home > Ask the Oracle Experts > SQL Questions & Answers > SQL FAQ: Common SQL questions, part 1
Ask The Oracle Expert: Questions & Answers
EMAIL THIS

SQL FAQ: Common SQL questions, part 1

Rudy Limeback EXPERT RESPONSE FROM: Rudy Limeback

Pose a Question
Other Oracle Categories
Meet all Oracle Experts
Become an Expert for this site


Oracle tips, scripts, and expert advice
Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google


>
QUESTION POSED ON: 05 July 2007

>
EXPERT RESPONSE

To celebrate our 600th "Ask The Expert" SQL column, we thought we'd run a special three-part answer, to highlight some of the common or frequently asked SQL questions we've seen over the past six years.

Please do keep sending in your questions. We love ’em.

Types of common SQL questions

Common SQL questions fall into three broad categories:

  1. novice questions
  2. homework questions
  3. serious SQL questions

1. Novice questions

Novice questions are usually very simple. They immediately reveal only limited degrees of familiarity with SQL. For example,

  • How can I delete all rows before a particular date?
    Answer: With a WHERE condition in the DELETE statement. Every basic SQL tutorial covers this.

  • I want only rows which have the same IDs in both tables
    Answer: Use an INNER JOIN. Actually not a bad question, if you've never seen or heard of joins, which many new programmers apparently have not.

  • What is the difference between Distinct and Unique?
    Answer: Also quite a reasonable question. They aren't synonyms in SQL, because each can be used only in very specific places in SQL statements—DISTINCT in a SELECT clause or COUNT(DISTINCT) expression, and UNIQUE when declaring a constraint. On the other hand, they are synonyms when talking about SQL, because when you use SELECT DISTINCT, you do get unique rows. So what to answer?

"What is the difference between ..." seems to be a common question.

  • What is the difference between "inner" and "outer" joins?
    Answer: Outer joins return unmatched rows. What more is there to say?

  • What is the difference between GROUP BY and ORDER BY clauses?
    Answer: One does grouping, the other does ordering. That might sound flippant, but it is not meant to be.

We really do like the short questions, because it gives us so much latitude in choosing the examples with which to illustrate the topic. But sometimes the question just isn't specific enough.

Then there are the "It depends" questions. These questions often exhibit reasonable knowledge of SQL. For example,

  • Which is faster, Functions Or Procedures, and why? Thanks, it's urgent!
    Answer: Both functions and procedures require more than a beginner's level of knowledge of SQL. Knowing which is faster might—might—sway the decision to use one or the other. However, too much depends on factors completely outside the question, such as what you're trying to accomplish. Furthermore, it is naïve to think there might be a difference in performance for all contexts. That's about all we can reasonably say on the subject. Try some benchmarks on your own database system. As for it being urgent, this does not influence whether we will answer your question.

Several "it depends" questions seem to come up over and over, and we try to answer them at least once. For example, here's one we've seen many times:

We get a steady supply of novice questions, and this is good. It indicates that new blood is constantly coming into the world of relational databases. While most of the questions are not interesting enough to be selected for an answer, we do read them all.

In Common SQL questions, part 2, we'll do a quick review of some common homework questions.


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google


RELATED CONTENT
SQL
Finding a column value inside a user-supplied string
Update a specific column in a field or row?
Using BETWEEN with DATETIMEs in SQL
Which normal form is used most?
IN list or series of OR conditions?
Connecting tables in a database
SQL query for co-authored books
Querying complex derived tables
SQL string functions
Changing a NULL column to NOT NULL

Oracle tutorials, tips and FAQs
How to create a database link in Oracle
Most clicked stories of 2007
How do I do that in Oracle?
Counting a row's NULL columns
How many redo log files?
How to start multiple instances in Oracle 10g
Is it possible to assign a role to a profile?
Difference between RECYCLEBIN and 'DROPPED' column
How to find transactions being committed to Oracle database
How to create a database schema in Oracle?
Oracle tutorials, tips and FAQs Research

Oracle SQL
SQL to count values of a status code
Counting NULL columns
Detail rows for accounts that occur three times
Counting a row's NULL columns
Oracle's free SQL Developer adds database migration tool
Latest transaction if no recent prior transactions
Three ways SQL can count rows by type
SQL to select only certain times within a date range
Oracle SQL to test for numerics
Number of rows in multiple tables
Oracle SQL Research

RELATED GLOSSARY TERMS
Terms from Whatis.com − the technology online dictionary
10g  (SearchOracle.com)
delimiter  (SearchOracle.com)
extent  (SearchOracle.com)
field  (SearchOracle.com)
flexfield  (SearchOracle.com)
foreign key  (SearchOracle.com)
Oracle  (SearchOracle.com)
row  (SearchOracle.com)

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary



Search and Browse the Expert Answer Center
Search and browse more than 25,000 question and answer pairs from more than 250 TechTarget industry experts.
Browse our Expert Advice

HomeNewsTopicsTipsAsk the ExpertsMultimediaWhite PapersProductsBlogs
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides enterprise IT professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective IT purchase decisions and managing their organizations' IT projects - with its network of technology-specific Web sites, events and magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Reprints  |  Site Map




All Rights Reserved, Copyright 2003 - 2008, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts