SIDE-BANNERCENTER-BANNERSIDE-BANNER * Oh God! Let there be PEACE. Make them calm, gentle, humble and stable. Make them realize their mistakes. Make them to confess, seek and pray for forgiveness. Let there be forgiveness for true hearts. Show them the right path on which they can walk. Let there be justice, satisfaction and happiness. Let them know that you are the justice and truth. Let them know that the innocent is never punished. Give them the strength, courage and wisdom to quit bad and to achieve good purpose. Let there be leaders who are followed by goodness. Make them competitive to achieve good. Remove their greed, wickedness and bad ambitions. Let them know that your love is infinite. Speak to them in simple ways so they understand. May your heart hear their pure hearts. * Never say die.Live and let live.* Accept Good if not, it Perishes.* What you Sow is what you Reap.* United we Stand divided we Fall.* Where there is a Will there is a Way.* Love is the strongest Power on earth.* When going gets Tough the Tough gets going.* For every problem created there is a perfect Solution.* When your hand starts paining you don't Cut it, Cure it.* A good purpose of life is the persistence to be constructive.* The arch of justice is wide, but it bends towards freedom and justice.* Lion king says he wants all the Power but none of the Responsibilities.* Life is a puzzle which can be solved by Hard work, Character and Discipline.* Money is like Manure, Spread it and it does good.* Pile it up in one place and it Stinks.* When a man wants to be a King he should exactly know the responsibilities of a King.* The only thing necessary for evil to triumph is for good men to do nothing - Edmund Burke.* Face is the reflection of mind.* A purpose of life is a life of purpose.* Beauty lies in the eyes of the beholder.* Necessity is the mother of all inventions. Real friends are those who help us in troubles.* Freedom and Power are lost if it’s miss utilized. Repeating mistakes will lead to sin and blunders.* Quantity is appreciated only when it has Quality.* Everyday is a new day, which brings hope with it.* Ego of superiority is the destruction of individuality.* We cannot learn to swim without going into the water.* Everything happens for good and thus leads to destiny.* Every problem has a perfect solution, we need to find them.* A good purpose of life is the persistence for constructiveness.* It’s hard to create good things where as it’s easy to break them.* Ideas are appreciated and respected only when we express them.* Mistakes do happen by humans, they are forgiven when we pray.* Freedom means giving others the right to achieve good purposes.* We have to put our efforts and leave the rest for destiny to decide.* All big things start with a first step.* First step is sometimes difficult.* Prayers come true when the purpose is good, thus pray for everyone.* Dreams come true when we have faith and pray for good things in life.* We got to have strength, courage and wisdom to achieve good things in life.* Every relationship has a meaning; we have to give them the proper meaning.* The only thing necessary for the triumph of evil is for good men to do nothing.* If wealth is lost, nothing is lost. If health is lost, something is lost. But, if character is lost, everything is lost.* “Stand up, be bold, be strong. Take the whole responsibility on your own shoulders, and know that you are the creator of your own destiny.” - Swami Vivekananda.
HOME-PAGEREALIZATIONQUOTESPUZZLESPRAYERSPERCEPTIONSMUSIC-DOWNLOADSTORIESJOKES
BOOKSBITTER-TRUTHANCIENT-SCRIPTURESBEAUTIFUL-LIFETHOUGHTSFRIENDSHIPPRAYERS-TO-WORSHIPWinning-Publications

QUANTITY is appreciated only when it has QUALITY. Recitation is the mother of Memory. Necessity is the mother of Invention. Knowledge grows when distributed. Enrichment for Information Technology. Persistence to be constructive is the key to success.

Thursday, February 14, 2008

Structured Query Language


What is SQL? (Online Testing) (Faqs-Index) (MySql-Index) (Tech-Index)
A: SQL stands for 'Structured Query Language'.

What is SELECT statement? (Sample-Table)
A: The SELECT statement lets you select a set of values from a table in a database. The values selected from the database table would depend on the various conditions that are specified in the SQL query.

How can you compare a part of the name rather than the entire name?
A: SELECT * FROM people WHERE empname LIKE '%ab%' Would return a recordset with records consisting empname, with the sequence 'ab' in empname.

What is the INSERT statement?
A: The INSERT statement lets you insert information into a database.

How do you delete a record from a database?
A: Use the DELETE statement to remove records or any particular column values from a database.

How could I get distinct entries from a table? (Online Database) (Create Query)
A: The SELECT statement in conjunction with DISTINCT lets you select a set of distinct values from a table in a database. The values selected from the database table would of course depend on the various conditions that are specified in the SQL query. Example:
SELECT DISTINCT empname FROM emptable.

How to get the results of a Query sorted in any order? (Index)
A: You can sort the results and return the sorted results to your program by using ORDER BY keyword thus saving you the pain of carrying out the sorting yourself. The ORDER BY keyword is used for sorting.
SELECT empname, age, city FROM emptable ORDER BY empname.

How can I find the total number of records in a table? (TechOnTheNet) (Index)
A: You could use the COUNT keyword , example:
SELECT COUNT(*) FROM emp WHERE age>40

What is GROUP BY? (MySql) (Faqs)
A: The GROUP BY keywords have been added to SQL because aggregate functions (like SUM) return the aggregate of all column values every time they are called. Without the GROUP BY functionality, finding the sum for each individual group of column values was not possible.

What is the difference among "dropping a table", "truncating a table" and "deleting all records" from a table. (Faqs-Index) (MySql-Index)
A: Dropping : (Table structure + Data are deleted), Invalidates the dependent objects ,Drops the indexes. (MySql) (Faqs)
Truncating: (Data alone deleted), Performs an automatic commit, Faster than delete. (MySql) (Faqs)
Delete : (Data alone deleted), Doesn't perform automatic commit. (MySql) (Faqs)
(Tech)

What are the Large object types supported by Oracle?
A: Blob and Clob. (Oracle)

Difference between a "where" clause and a "having" clause.
A: HAVING clause is used only with group functions whereas WHERE is not used with. Having Ex:1. Ex2. Where Ex:1. Ex:2.

What's the difference between a primary key and a unique key?
A: Both primary key and unique enforce uniqueness of the column on which they are defined. But by default primary key creates a clustered index on the column, where as unique creates a non-clustered index by default. Another major difference is that, primary key doesn't allow NULLs, but unique key allows one NULL only.

What are cursors? Explain different types of cursors. What are the disadvantages of cursors? How can you avoid cursors?
A: Cursors allow row-by-row processing of the result sets. Types of cursors:
Dynamic, Keyset-driven, Static and Forward-only. See below for more information. Disadvantages of cursors: Each time you fetch a row from the cursor, it results in a network round-trip, where as a normal SELECT query makes only one round-trip, however large the result-set is. Cursors are also costly because they require more resources and temporary storage (results in more IO operations). Further, there are restrictions on the SELECT statements that can be used with some types of cursors. Most of the times, set based operations can be used instead of cursors.
The four types of cursors supported by Transact-SQL:
DYNAMIC, KEYSET, STATIC, and FORWARD_ONLY. Difference lies with how the data is traversed by the cursor.
(1)Type (2)Scrollable (3)Membership/Order (4)Column Values (5)Description
(1)DYNAMIC/SENSITIVE (2)Yes (3)Dynamic (4)Dynamic
(5)View additions, changes, and deletions by other users while cursor is open.
(1)KEYSET (2)Yes (3)Fixed (4)Dynamic
(5)View changes, but not additions and deletions while the cursor is open.
(1)STATIC / INSENSITIVE (2)Yes (3)Fixed (4)Fixed
(5)View only a copy of the data; cannot view additions, changes, or deletions
while cursor is open.
(1)FORWARD_ONLY (default) (2)No (3)Dynamic (4)Dynamic
(5)Same as Static cursor but can only scroll forward through a table.

A DYNAMIC cursor allows us to move freely throughout your record-set, without restrictions, except when our provider does not support bookmarks.
A FORWARD-ONLY cursor (the default) returns rows sequentially from the database. It does not require space in tempdb, and changes made to the underlying data are visible as soon as they're reached.

What are triggers? How to invoke a trigger on demand?
A: Triggers are special kind of stored procedures that get executed automatically when an INSERT, UPDATE or DELETE operation takes place on a table. Triggers can't be invoked on demand. They get triggered only when an associated action (INSERT, UPDATE, DELETE) happens on the table on which they are defined. Triggers are generally used to implement business rules, auditing. Triggers can also be used to extend the referential integrity checks, but wherever possible, use constraints (Wiki) for this purpose, instead of triggers, as constraints are much faster.

Where do we use these statements?
1. SELECT 2. DISTINCT 3. WHERE 4. AND OR 5. IN 6. BETWEEN 7. LIKE 8. ORDERBY
4, 5, 6 and 7 are used in conjunction with WHERE statement.
8 is used with or without WHERE statement with DESC or ASC.

What’s the meaning of:
*’A_Z’ *’ABC%’ *’%XYZ’ *‘%AN%’
These are used with LIKE keyword.
*’A_Z’ String that starts with A and ends with Z with any single character between them.
*’ABC%’ String that starts with ABC and end with any number of characters.
*’%XYZ’ String that starts with any number of characters and ends with XYZ.
*’%AN%’ String that starts and ends with any number of characters with embedded AN characters.

FUNCTIONS: Used to do math on numbers.
1. AVG(column name) 2. COUNT(column) 3. MAX(column) 4. MIN(column) 5. SUM(column)
These are used with SELECT statements.
Ex: SELECT SUM(Column-Sales) FROM Table-Store_Information. (Sum of all sales values)
SELECT COUNT(Column-Store_Name) FROM Table-Store_Information. (Count number of rows in column)
SELECT COUNT(DISTINCT Column-Store_Name) FROM Table-Store_Information. (Count number of distinct rows in column)
SELECT MAX(Column-Sales) FROM Table-Store_Information. (Get maximum value in column)
SELECT MIN(Column-Sales) FROM Table-Store_Information. (Get minimum value in column)

GROUP BY: Keyword (Used with aggregate functions)
Used to get distinct values in columns when using math functions. Used under Conditions: Selecting multiple columns from table, at least one arithmetic operator is used, GROUP BY is applied at the end of the statement.

HAVING: Keyword (Used with aggregate functions). If it’s not an aggregate function then WHERE can be used.
Ex: SELECT store_name, SUM(sales) FROM Store_Information GROUP BY store_name HAVING SUM(sales) > 1500
Result:
store_name SUM(Sales)
Los Angeles $1800

Alias Names: Used to give easy shortcut names to Columns and Tables. To give easy readable column headings in output results if the column name is big or complicated or when using arithmetic operations like SUM(name) etc. Where as Table alias is used to make clear and easy query statements by replacing the real table names with shortcuts. When querying multiple columns it’s convenient to use alias shortcut names to represent columns from different tables.
SELECT A1.store_name “Store”, SUM(A1.Sales) “Total Sales” FROM Store_Information A1 GROUP BY A1.store_name

* What is a join and explain different types of joins? (Wiki)
A: Joins are used in queries to explain how different tables are related. Joins also let you select data from a table depending upon data from another table.
Different types of joins are classified based on the display of results.
Types of joins: INNER JOIN (No Null) and OUTER JOIN (Contain Null).
Inner join can be CROSS or EQUI Join.
OUTER JOIN is further classified as LEFT OUTER JOIN, RIGHT OUTER JOIN and FULL OUTER JOIN.

Join: (or Inner Join): Used when Two Tables have common fields in columns represented by WHERE clause.
GROUP BY columns other than the common columns. (Does not contain NULL in result)
Ex: SELECT A1.region_name REGION, SUM(A2.Sales) SALES FROM Geography A1, Store_Information A2 WHERE A1.store_name = A2.store_name GROUP BY A1.region_name
Result:
REGION SALES
East $700
West $2050
* Equi-join(Explicit Inner join).
Ex: SELECT * FROM
Geography INNER JOIN Store_Information ON Geography.store_name = Store_Information.store_name
(Displays two store_name columns without any NULL values)
* Natural join(implicit inner join).
Ex: SELECT * FROM
Geography NATURAL JOIN Store_Information
(Displays single store_name column without any NULL values)
(OR) SELECT * FROM
Geography, Store_Information WHERE Geography.store_name = Store_Information.store_name

Outer Join: (Left or Right Join): Used when Two tables have common fields in columns represented by WHERE clause.
GROUP BY columns which are common columns. (May contain NULL in result).
* Left outer join: Contains all records of the "LEFT" table, at least once. NULL will appear if no records are matched from the RIGHT table.
Ex: SELECT * FROM
Geography LEFT OUTER JOIN Store_Information ON Geography.store_name = Store_Information.store_name
Ex of Left Outer Join: SELECT A1.store_name, SUM(A2.Sales) SALES FROM Geography A1, Store_Information A2 WHERE A1.store_name = A2.store_name (+) GROUP BY A1.store_name
Result:
store_name SALES
Boston $700
New York Null
Los Angeles $1800
San Diego $250
* Right outer join: Contains every record from the "RIGHT" table, at least once. NULL will appear if no records are matched from the left table.
Ex: SELECT * FROM
Geography RIGHT OUTER JOIN Store_Information ON Geography.store_name = Store_Information.store_name

What is a self join?
A: Self join is just like any other join, except that two instances of the same table will be joined in the query.

* SQL Sub query: Used to embed one sql statement within another, with WHERE or HAVING statements to join tables.
Ex: SELECT SUM(Sales) FROM Store_Information
WHERE Store_name IN (SELECT store_name FROM Geography WHERE region_name = ‘west’)
Result:
SUM (Sales)
2050

SQL Union: Used to combine two queries, from different tables to select distinct values. Condition: Selected result data type from both table columns must be same.
Ex: SELECT Date FROM Store_Information UNION SELECT Date FROM Internet_Sales
Result: Distinct values from both tables. (Values without repetitions.)
Note: “SELECT DISTINCT Date” will also give the same result.

SQL Union All: Used to combine two queries, from different tables to select all the values. Condition: Selected result data type from both table columns must be same.
Ex: SELECT Date FROM Store_Information UNION ALL SELECT Date FROM Internet_Sales
Result: All the values are displayed. (Not distinct). (Values with repetitions.)

SQL Intersect: Used to select only common distinct values in columns from different tables with two query statements. Condition: Selected result data type from both table columns must be same.
Ex: SELECT Date FROM Store_Information INTERSECT SELECT Date FROM Internet_Sales
Result: Only common distinct values. (Common values present in both tables without repetitions.)

SQL Minus: Used to select only uncommon distinct values in columns from the first table only, with two queries. Condition: Selected result data type from both table columns must be same.
Ex: SELECT Date FROM Store_Information MINUS Date FROM Internet_Sales
Result: Only uncommon distinct values from first table. (Uncommon values from first table without repetitions.)



Read: Peace

Home Add to Google

"WE" has More Power than "I". Its a collective effort to create good things in life. Please let me know if you encounter any problems or have any suggestions. Please leave a comment and keep me informed.

*[Winning-in-Losing.] *[Miracles.] *[Life-is-full-of-Tests.] *[Never-Lose-Hope.] *[Interview-With-God.]
Prayers-To-Worship.
*Please-do-not-leave-me-ever. *Let’s-make-it-happen. *Faith-in-Patience. *The-only-one-I've-got. *Someone-somewhere. *How-I-Love-You. *Will-You? *Successful-Life. *Please-say-something. *Way-to-Paradise. *My-Everything.

No comments:

About Me

My photo
Simple guy who believes in being Competitive rather than being Ambitious. Persistence to be constructive, without frustrations, is a good purpose of life.
.

* * * * * * * * * * * * *

MeetUp Message Board:
Read: Wishes-and-Prayers. *Issue-of-Illegal-Immigration-&-Happy-Kingdom. *The-New-York-Hillary-Rodham-Clinton *Cast-God-Religion! *Barack-Obama-Meetup *Duty- Responsibility-Law-and-Order *John-Edwards-One-America *Good-Wishes-Life-is-Meaningful-&-Beautiful *Dennis-Kucinich-Meetup *Let-there-be-peace! *Bill-Richardson-for-President-2008 *Logic-of-Good-and-Bad-convert-bad-to-good *MORAL-STORY-Elephants-held-by-small-ropes.
* * * * * * * * * * * * *

Realizations.
*Realizations-In-Real-Life-Please-be-gentle-and-humble. *Manoj-D-Kargudri. *Amazing-Constructive-Vibrations. *Astrology. *Creating-Leaders. *How-ideas-are-concluded-and-decisions-are-materialized. *“Relationships-in-Life”-“Partnerships-in-Life”. *The-path-of-victory-the-path-of-life-winning-in-looseing. *An-attempt-for-definition. *Speak-with-a-heart. *These-are-contagious. *Key-to-happy-kingdom. *MIRACLES. *Better-to-create-one! *Cast-God-and-Religion! *Manoj-Kargudri. *Things-become-inevitable! *We-are-all-looking-for! *Phase-of-Life. *Destiny-Karma-and-God. *Struggle-perfection-and-Money. *Independence-and-Freedom. *Relationships-and-Happiness.
* * * * * *

Quotes.
*Love-Compassion-Tolerance-Forgiveness-Courtesy. *Manoj-D-Kargudri. *True-to-Heart-going-back-to-Basics!
* * * * * *

Puzzles-Riddles-Think.
*River-Crossing-Puzzles-Brain-Teasers. *Manoj-Kargudri. *Perpetual-Motion-Gravity-and-Kinetics. *Illusions-Paradoxes-Perpetually-ascending-staircase. *Milk-man-with-no-measureing-jar. *Amazing-Horoscope-Mind-Reader. *Find-the-hidden-images-in-these-STEREOGRAMS. *Are-they-12-or-13? *What-would-U-do? *ABCD-Four-Digit-Number. *10-Digit-Number. *4-QUESTIONS...GOOD-LUCK! *Think-Wise.
* * * * * *

Prayers.
*God-gave-us-everything-we-ever-needed. *Good-Wishes. *Manoj-Kargudri. *Love-Compassion-Tolerance-Forgiveness-Courtesy. *Interview-With-God! *He-is-the-one! *Candle-of-Hope! *Let-there-be-Peace! *Manoj-Kargudri.
* * * * * *

Perceptions.
*Issue-of-Illegal-Immigration. *To-which-religion-does-this-universe-belongs-to? *Law-and-order-helps-to-maintain-justice. *Implementing-regulations-by-justice. *Putting-our-sincere-efforts. *Religion-and-cast. *Impact-of-reservation-based-on-religion-and-cast. *Free-and-Fare-Education-system-Electoral-system.
* * * * * *

Stories.
*The-Monkey’s-Justice-for-two-cats. *The-Blind-Men-And-The-Elephant. *Manoj-Kargudri. *Two-rich-merchants-and-a-thief. *Healing-is-contagious. *Two-saints-in-a-market-place. *A-Terrible-Fight-Between-Two-Wolves. *Hen-that-laid-golden-eggs. *Healing-forgiveness-and-affection. *Elephants-held-by-small-ropes. *Story-of-Punyakoti-the-strength-of-truth. *What-is-the-reason? *Reply-Depends-on-the-Question. *Critical-mass-Experiment. *The-Brahman's-Wife-and-the-Mongoose. *The-Boy-Who-Cried-Wolf. *Difference-between-Heaven-and-Hell! *Freedom-and-Prison! *It's-in-Your-Eyes!
* * * * * *

Jokes.
*Please-listen-to-me. *The-Silent-Treatment! *Surgeon-Vs-Mechanic. *Manoj-Kargudri. *God's-doing-a-lot-better-job-lately.
* * * * * *

The-Bitter-Truth.
*Duty-Responsibility-Law-and-Order. *"Happy-Kingdom"-proudly-proclaimed-as-"Paradise". *Trying-to-learn-something-for-the-first-time. *Time-is-the-only-solution. *For-every-Action-there-is-an-Equal-and-Opposite-Reaction. *Logic-of-Good-and-Bad. *Manoj-Kargudri. *Duties-Responsibilities-verses-Luxuries-and-Pleasures. *Beggars!
* * * * * *

Life-is-Beautiful.
*Creating-successful-constructive-personality. *Why-God-Gave-Us-Friends? *Way-to-Paradise. *Creating-the-Beautiful-World. *Doing-the-job-of-goodness. *Life-is-Meaningful. *Manoj-Kargudri. *The-A-to-Z-for-Goodness. *Life-is-full-of-Tests. *History-Proves-That. *Love-in-different-forms. *True-to-the-heart.
* * * * * *

Prayers-To-Worship.
*Please-do-not-leave-me-ever. *Let’s-make-it-happen. *Faith-in-Patience. *The-only-one-I've-got. *Someone-somewhere. *How-I-Love-You. *Will-You? *Successful-Life. *Manoj-Kargudri. *Please-say-something. *Way-to-Paradise. *My-Everything.
* * * * * *

Friendship.
*Life-Still-Has-A-Meaning. *Heavenly-Garden. *GOD-SPEAK-TO-ME! *Why-God-Made-Friends? *I-asked-the-Lord! *A-Best-Friend! *Why-GOD-Gave-Us-Friends? *Portrait-of-a-Friend. *Friends-till-the-end. *Some-Assorted! *Forever-Friends. *What-is-a-friend!
* * * * * *

Winning-Publications.
*Significance-of-Nava-ratna (Nava-Graha). *Amazing-Constructive-Vibrations. *Manoj-Kargudri. *The-piercing-of-the-ears (karnavedha) . *Nature-Cure. *Steps-to-improve-work-place. *Steps-Involved-In-Relationships. *Some-of-the-aspects-which-materialize-the-relationships.
* * * * * *

Music-Download.
*Bhakti-Songs. *Manoj-Kargudri. *English-Songs. *Gazal-Bhajan-Hindi. *Hindi-Life. *Hindi-Love. *Hindi-Old-Kishore. *Hindi-Old-Mukesh. *Hindi-Old-Songs. *Hindi-Rock. *Hindi-Pops. *Instrumental. *Vocal-Ragas.
* * * * * *

Technology.
*READ: Why-JAVA *Manoj-Kargudri. *Start-Learning-JAVA *Why-Java's-Hot *Start-Using-LINUX *Java-Q-&-A *Question *Java-SE-6-Doc *Struts-Doc *Java-Tutorial-Index *Java-Certification *Tech. *Struts. *Manoj-Kargudri. *Servlet. *JSP. *EJB. *JNDI-JMS *SQL. *JDBC. *CORE-JAVA: *OOP *CLASS. *Manoj-Kargudri. *ABSTRACT *EXCEPTIONS *THREADS *UTILS *PACKAGES *JVM *CASTING *NETWORKING *RMI-XML
* * * * * *

MUSIC-DOWNLOAD.
*Hindi-Vocal-Raga. *Hindi-Remix-Rock. *Hindi-Old-Songs. *Hindi-Mukesh-Mohd-Rafi-Songs. *Hindi-LOVE-Songs. *Hindi-Remix-LIFE. *English-Rock-Songs. *Kannada-Janapada-Geete. *Kannada-Film-Songs. *Kannada-Devotional-Songs. *Instrumental-Music. *Manoj-Kargudri. *Hindi-Pop-Songs. *Hindi-Bhakti-Songs. *Hindi-Kishore-Kumar-SAD. *Hindi-Kishore-Kumar-JOY. *Hindi-R-D-Burman. *Hindi-Gazals. *English-Soft-Songs.
* * * * * *