<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-2967271806809978211</id><updated>2012-02-16T09:33:14.262-08:00</updated><category term='How to Drop undo Tablespace'/><category term='SYSDATE Functions'/><category term='Practice Numeric Functions'/><category term='Deleting duplicate rows in the table'/><category term='INTERVIEW QUESTIONS'/><category term='Scan n Skip Scan In Oracle'/><category term='who is Scott?'/><category term='sql plus'/><category term='Combining Search Conditions'/><category term='Database Crashed'/><category term='SubstitutionVariable'/><category term='Create Oracle Host'/><category term='Interview Questions-5'/><category term='Like n Null'/><category term='Practice USER'/><category term='Deadlock'/><category term='CPU Resources'/><category term='Backup n Recovery Tips'/><category term='Log block size'/><category term='Renaming A Datafile'/><category term='Tuning a Wait Session'/><category term='Time Left For Query Completion'/><category term='Finding How Much Data Has Been Filled'/><category term='Oracle&apos;s Head HQ'/><category term='Problems with Password File'/><category term='Update statements in Query'/><category term='values back to unix'/><category term='Practice OTHER FUNCTIONS'/><category term='Pros'/><category term='plan tips'/><category term='Using Trigger And Procedure Together'/><category term='Practice DATE FUNCTIONS'/><category term='How to create a DBMS Job'/><category term='Droping Logfile Group Failed'/><category term='Implementing Joins-2'/><category term='Compute By Clause'/><category term='So'/><category term='Query about Data Storage and Retrieval'/><category term='Creating Dimensions in 8i'/><category term='List prerequisites to connect to oracle'/><category term='Modify the Primary Key Order-sql tip'/><category term='User rights'/><category term='Dynamic Table Names and Moving Table'/><category term='What is SQL?'/><category term='Legato'/><category term='How Can I Copy Data in Another System'/><category term='How to init an object type'/><category term='happy new year'/><category term='Can we Change a Column Name'/><category term='EBU/Rman'/><category term='Oracle Service Consuming Lot of CPU Resource'/><category term='SELECT INTO'/><category term='Shell Script To Dynamically Generate Init.ora File'/><category term='one PL/SQL procedure to housekeep a table'/><category term='Man behind Oracle'/><category term='Implementing Joins-1'/><category term='Oracle loction on linux'/><category term='Aggregate Functions with Groupby n Having clause'/><category term='SELECT clause'/><category term='Change the Port number'/><category term='Problem Running &apos;ckrorole.sql&apos; in Sqlplus'/><category term='Tablespace Change'/><category term='Why this Query Returns null'/><category term='Deleting all objects from a tablespace'/><category term='What is SQLall about?'/><category term='Shutting Down Oracle On Windows'/><category term='Using  WHERE'/><category term='&apos;SNIPED&apos; status'/><category term='Save an Image'/><category term='Sols for DBA’s'/><category term='Range and  List operators'/><category term='linking libraries'/><category term='What a Schema Is'/><category term='Best way to compare two Databases'/><category term='Qs n As'/><category term='Select Entries from Whole Week-SqlTip'/><category term='Oracle_SID'/><category term='Sql TIps'/><category term='Datafiles Efficiency: More Files vs Increase the Size'/><category term='Interview Questions-1'/><category term='Cloning Database'/><category term='Unable to locate statement causing error'/><category term='Unable to Create a New Instance'/><category term='Database not Opening'/><category term='Autotrace on 8i'/><category term='Multiple fields'/><category term='Referential Integrity'/><category term='Update B with the Help of A'/><category term='Oracle Performance On Different Platforms'/><category term='Login Problem'/><category term='Interview Questions-2'/><category term='Error in PL/SQL block of trigger'/><category term='Oracle FAQ'/><category term='Practice CONVERSION FUNCTIONS'/><category term='Sub Queries'/><category term='Practice AGGREGATE FUNCTIONS'/><category term='Oracle General Ledger'/><category term='What are Relational Databases?'/><category term='Forms4.5FAQ'/><category term='Changing Prompt in SQL Plus'/><category term='Reducing Database Fragmentation'/><category term='Hit Ratios'/><category term='Accessing Oracle Database'/><category term='Modifying A Column Of A Table-Sql Tip'/><category term='Interview Questions-3'/><category term='Date Functions'/><category term='Is IMPORT n EXPORT is platform dependent'/><category term='Use user defined functions in SQL'/><category term='Formatting Columns'/><category term='How to Start the Service Manager'/><category term='TEXT_IO code'/><category term='HAVING AND ORDER BY clauses together'/><category term='How much memory is been utilized by the SGA'/><category term='Practicce CHARACTER FUNCTIONS'/><category term='Hindi Format in Orcl'/><category term='Distinct n order by'/><category term='PLSql'/><category term='java.sql.SQLException'/><category term='Elapsedtime'/><category term='What is PL/SQL tables'/><category term='What are Dabase Models ?'/><category term='Interview Questions-4'/><category term='setup for calling'/><category term='Literals'/><category term='GROUP BY'/><category term='Size Of Database'/><category term='Small Select Statement'/><category term='Editing commands'/><category term='Sql Via Command Prompt'/><category term='Securing Database 9i'/><category term='SQL FUNCTIONS-Expressions'/><category term='Snapshot too old error'/><title type='text'>ORACLE</title><subtitle type='html'>InterviewQues, faqs, SQL,sql+, PlSql,my sql, Sqlserver, Ms Sql, 7i,8i,9i,10i,  SNIpEDstatus, Cloning Database, CPU Resources, Database Crashed, Deadlock, Editing commands, Elapsedtime, Formating Columns, Forms4.5FAQ, Hindi Format, Hit Ratios, Log block size, Multiple fields, Orcl loction on linux, Oracle_SID, Plan TIps,setup for calling, Snapshot too old error,Sols for DBA’s,Sql Via Command Prompt,values back to unix,Schema,Faqs, Interview questions and Real time stuff too,,</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://oracledbs.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://oracledbs.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default?start-index=101&amp;max-results=100'/><author><name>Real Time Scenario</name><uri>http://www.blogger.com/profile/11930020132547308855</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>130</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-2967271806809978211.post-6550001384173336576</id><published>2008-04-06T12:00:00.000-07:00</published><updated>2008-04-06T12:54:33.764-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='INTERVIEW QUESTIONS'/><title type='text'>ORACLE INTERVIEW QUESTIONS</title><content type='html'>&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="color:#993300;"&gt;&lt;/span&gt;&lt;/strong&gt; &lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="color:#993300;"&gt;What are the components of physical database structure of Oracle database?&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;Oracle database is comprised of three types of files. One or more datafiles, two are more redo log files, and one or more control files.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="color:#993300;"&gt;&lt;/span&gt;&lt;/strong&gt; &lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="color:#993300;"&gt;What are the components of logical database structure of Oracle database?&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;There are tablespaces and database's schema objects.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;/strong&gt; &lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="color:#993300;"&gt;What is a tablespace?&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;A database is divided into Logical Storage Unit called tablespaces. A tablespace is used to grouped related logical structures together.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="color:#993300;"&gt;&lt;/span&gt;&lt;/strong&gt; &lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="color:#993300;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;script type="text/javascript"&gt;&lt;!--&lt;br /&gt;google_ad_client = "pub-0226036909544779";&lt;br /&gt;/* 300x250, created 06/04/08 */&lt;br /&gt;google_ad_slot = "4449867954";&lt;br /&gt;google_ad_width = 300;&lt;br /&gt;google_ad_height = 250;&lt;br /&gt;//--&gt;&lt;br /&gt;&lt;/script&gt;&lt;br /&gt;&lt;script type="text/javascript"&lt;br /&gt;src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;&lt;br /&gt;&lt;/script&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;What is SYSTEM tablespace and when is it created?&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;Every Oracle database contains a tablespace named SYSTEM, which is automatically created when the database is created. The SYSTEM tablespace always contains the data dictionary tables for the entire database.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="color:#993300;"&gt;&lt;/span&gt;&lt;/strong&gt; &lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="color:#993300;"&gt;Explain the relationship among database, tablespace and data file ?&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;Each databases logically divided into one or more tablespaces one or more data files are explicitly created for each tablespace.What is schema?A schema is collection of database objects of a user.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;/strong&gt; &lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;a href="http://cinfonet.blogspot.com/"&gt;What are Schema Objects?&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;Schema objects are the logical structures that directly refer to the database's data. Schema objects include tables, views, sequences, synonyms, indexes, clusters, database triggers, procedures, functions packages and database links.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="color:#993300;"&gt;&lt;/span&gt;&lt;/strong&gt; &lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="color:#993300;"&gt;Can objects of the same schema reside in different tablespaces?&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;Yes.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="color:#993300;"&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="color:#993300;"&gt;&lt;/span&gt;&lt;/strong&gt; &lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="color:#993300;"&gt;Can a tablespace hold objects from different schemes?&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;Yes.&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="color:#993300;"&gt;&lt;/span&gt;&lt;/strong&gt; &lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="color:#993300;"&gt;What is Oracle table?&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;A table is the basic unit of data storage in an Oracle database. The tables of a database hold all of the user accessible data. Table data is stored in rows and columns.&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="color:#993300;"&gt;&lt;/span&gt;&lt;/strong&gt; &lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="color:#993300;"&gt;What is an Oracle view?&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;A view is a virtual table. Every view has a query attached to it. (The query is a SELECT statement that identifies the columns and rows of the table(s) the view uses.)&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2967271806809978211-6550001384173336576?l=oracledbs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracledbs.blogspot.com/feeds/6550001384173336576/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2967271806809978211&amp;postID=6550001384173336576' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/6550001384173336576'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/6550001384173336576'/><link rel='alternate' type='text/html' href='http://oracledbs.blogspot.com/2008/04/oracle-interview-questions.html' title='ORACLE INTERVIEW QUESTIONS'/><author><name>Real Time Scenario</name><uri>http://www.blogger.com/profile/11930020132547308855</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2967271806809978211.post-187779035664791748</id><published>2008-03-16T23:25:00.000-07:00</published><updated>2008-03-16T23:32:31.390-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='So'/><category scheme='http://www.blogger.com/atom/ns#' term='who is Scott?'/><title type='text'>So, who is Scott?</title><content type='html'>&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Bruce Scott was one of the first employees at Oracle (then Software  Development Laboratories). He was co-author and co-architect of Oracle V1, V2  and V3. The SCOTT schema (EMP and DEPT tables), with password TIGER, was created  by him. Tiger was the name of his cat.&lt;/p&gt; &lt;p&gt;After leaving Oracle, Bruce co-founded Gupta Technology (now known as Centura  Software) in 1984 with Umang Gupta, and later became CEO and founder of  PointBase, Inc.&lt;/p&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Image Of SCOTT&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://bp0.blogger.com/__HBlejBzk1Q/R94PYjZG-zI/AAAAAAAAAA0/lw-fSbBE9Mw/s400/scott.jpg" alt="" id="BLOGGER_PHOTO_ID_5178593536014482226" border="0" /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2967271806809978211-187779035664791748?l=oracledbs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracledbs.blogspot.com/feeds/187779035664791748/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2967271806809978211&amp;postID=187779035664791748' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/187779035664791748'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/187779035664791748'/><link rel='alternate' type='text/html' href='http://oracledbs.blogspot.com/2008/03/so-who-is-scott.html' title='So, who is Scott?'/><author><name>Real Time Scenario</name><uri>http://www.blogger.com/profile/11930020132547308855</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://bp0.blogger.com/__HBlejBzk1Q/R94PYjZG-zI/AAAAAAAAAA0/lw-fSbBE9Mw/s72-c/scott.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2967271806809978211.post-3329993075566955474</id><published>2008-03-16T23:07:00.000-07:00</published><updated>2008-03-16T23:22:11.171-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Man behind Oracle'/><title type='text'>Who is the man behind Oracle Corporation?</title><content type='html'>&lt;p&gt;Lawrence Joseph (Larry) Ellison (Born: 1944, Chicago) is president and CEO of  Oracle corporation.&lt;/p&gt; &lt;p&gt;He's the Oracle worlds hero, and he should be. Oracle Corporation, the  company he founded with Robert N. (Bob) Miner and Edward A. (Ed) Oates back in  1977, has emerged as the world's largest vendor of software that helps large  corporations and governments better manage their information.&lt;/p&gt; &lt;p&gt;Check out the book: &lt;span class="bb-url"&gt;What's the  difference between God and Larry Ellison&lt;/span&gt;".&lt;br /&gt;It's really a great book, and  is pretty even handed with who Larry Ellison is with lots of interesting stories  from the early days of Oracle. The name of the book came from a funny e-mail  message that went around the company. The answer to the question is: "God  doesn't think he's Larry..."&lt;/p&gt;&lt;p&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://bp2.blogger.com/__HBlejBzk1Q/R94NmDZG-xI/AAAAAAAAAAk/0Cmusig1GXs/s400/ellison-boss+os+oracle.jpg" alt="" id="BLOGGER_PHOTO_ID_5178591568919460626" border="0" /&gt;&lt;/p&gt;&lt;br /&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://bp0.blogger.com/__HBlejBzk1Q/R94NmjZG-yI/AAAAAAAAAAs/zfOC1Qtobmw/s400/miner.jpeg" alt="" id="BLOGGER_PHOTO_ID_5178591577509395234" border="0" /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2967271806809978211-3329993075566955474?l=oracledbs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracledbs.blogspot.com/feeds/3329993075566955474/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2967271806809978211&amp;postID=3329993075566955474' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/3329993075566955474'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/3329993075566955474'/><link rel='alternate' type='text/html' href='http://oracledbs.blogspot.com/2008/03/who-is-man-behind-oracle-corporation.html' title='Who is the man behind Oracle Corporation?'/><author><name>Real Time Scenario</name><uri>http://www.blogger.com/profile/11930020132547308855</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://bp2.blogger.com/__HBlejBzk1Q/R94NmDZG-xI/AAAAAAAAAAk/0Cmusig1GXs/s72-c/ellison-boss+os+oracle.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2967271806809978211.post-5663674641899896508</id><published>2008-03-16T22:49:00.000-07:00</published><updated>2008-03-16T23:03:54.444-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Oracle&apos;s Head HQ'/><title type='text'>Oracle's Head Quarters</title><content type='html'>&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold; color: rgb(102, 0, 0);"&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Who is Oracle and where do they come from?&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt; &lt;h3 style="color: rgb(0, 0, 153);"&gt;&lt;a name="Oracle_at_a_glance"&gt;Oracle at a glance&lt;/a&gt;&lt;/h3&gt;   &lt;p&gt;&lt;span style="font-weight: bold;"&gt;Global Workforce:&lt;/span&gt; 43,000&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Revenues 2004:&lt;/span&gt; $10.15 billion&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Net income 2004:&lt;/span&gt; $2.6 billion&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp1.blogger.com/__HBlejBzk1Q/R94JHzZG-uI/AAAAAAAAAAM/HNQurPWXS4E/s1600-h/orahq.jpg"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer;" src="http://bp1.blogger.com/__HBlejBzk1Q/R94JHzZG-uI/AAAAAAAAAAM/HNQurPWXS4E/s400/orahq.jpg" alt="" id="BLOGGER_PHOTO_ID_5178586651181906658" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Oracle Corporation was founded in 1977 in Redwood, California. They  introduced the first Relational Database Management System based on the &lt;span style="font-weight: bold;"&gt;IBM System/R&lt;/span&gt; model and the first database  management system utilizing IBM's Structured Query Language (&lt;span style="font-weight: bold;"&gt;SQL&lt;/span&gt;) technology.&lt;/p&gt; &lt;p&gt;Today, the Oracle DBMS is supported on over 80 different operating  environments, ranging from IBM mainframes, DEC VAX minicomputers, UNIX-based  minicomputers, Windows NT and several proprietary hardware-operating system  platforms, and is clearly the world's largest RDBMS vendor.&lt;/p&gt; &lt;p&gt;Oracle employs more than 43,000 professionals in 93 countries around the  world. Their expenditure for research and development is approximately 13% of  their revenue.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp1.blogger.com/__HBlejBzk1Q/R94JHzZG-vI/AAAAAAAAAAU/mkU029muxXk/s1600-h/orahq1.jpg"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer;" src="http://bp1.blogger.com/__HBlejBzk1Q/R94JHzZG-vI/AAAAAAAAAAU/mkU029muxXk/s400/orahq1.jpg" alt="" id="BLOGGER_PHOTO_ID_5178586651181906674" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp3.blogger.com/__HBlejBzk1Q/R94JITZG-wI/AAAAAAAAAAc/bTo72wFZK7I/s1600-h/orahq2.jpg"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer;" src="http://bp3.blogger.com/__HBlejBzk1Q/R94JITZG-wI/AAAAAAAAAAc/bTo72wFZK7I/s400/orahq2.jpg" alt="" id="BLOGGER_PHOTO_ID_5178586659771841282" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-weight: bold;"&gt;Oracle's Head HQ&lt;/span&gt; buildings in Redwood Shores&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2967271806809978211-5663674641899896508?l=oracledbs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracledbs.blogspot.com/feeds/5663674641899896508/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2967271806809978211&amp;postID=5663674641899896508' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/5663674641899896508'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/5663674641899896508'/><link rel='alternate' type='text/html' href='http://oracledbs.blogspot.com/2008/03/oracles-head-quarters.html' title='Oracle&apos;s Head Quarters'/><author><name>Real Time Scenario</name><uri>http://www.blogger.com/profile/11930020132547308855</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://bp1.blogger.com/__HBlejBzk1Q/R94JHzZG-uI/AAAAAAAAAAM/HNQurPWXS4E/s72-c/orahq.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2967271806809978211.post-6471824363687037982</id><published>2008-02-08T04:56:00.000-08:00</published><updated>2008-02-08T05:04:48.534-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Interview Questions-5'/><title type='text'>Interview Questions</title><content type='html'>&lt;div style="text-align: center;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;br /&gt;&gt;&gt;Previous&gt;&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;51.What is an execution plan? When would you use it? How would you view the execution plan?&lt;br /&gt;&lt;br /&gt;52.What is the STUFF function and how does it differ from the REPLACE function?&lt;br /&gt;&lt;br /&gt;53.What does it mean to have quoted_identifier on? What are the implications of having it off?&lt;br /&gt;&lt;br /&gt;54.What are the different types of replication? How are they used?&lt;br /&gt;&lt;br /&gt;55.What is the difference between a local and a global variable?&lt;br /&gt;&lt;br /&gt;56.What is the difference between a Local temporary table and a Global temporary table? How is each one used?&lt;br /&gt;&lt;br /&gt;57.What are cursors? Name four types of cursors and when each one would be applied?&lt;br /&gt;&lt;br /&gt;58.What is the purpose of UPDATE STATISTICS?&lt;br /&gt;&lt;br /&gt;59.How do you use DBCC statements to monitor various aspects of a SQL server installation?&lt;br /&gt;&lt;br /&gt;60.How do you load large data to the SQL server database?&lt;br /&gt;&lt;br /&gt;61.How do you check the performance of a query and how do you optimize it?&lt;br /&gt;&lt;br /&gt;62.How do SQL server 2000 and XML linked? Can XML be used to access data?&lt;br /&gt;&lt;br /&gt;63.What is SQL server agent?&lt;br /&gt;&lt;br /&gt;63.What is referential integrity and how is it achieved?&lt;br /&gt;&lt;br /&gt;64.What is indexing?&lt;br /&gt;&lt;br /&gt;65.What is normalization and what are the different forms of normalizations?&lt;br /&gt;&lt;br /&gt;66.Difference between server.transfer and server.execute method?&lt;br /&gt;&lt;br /&gt;67.What id de-normalization and when do you do it?&lt;br /&gt;&lt;br /&gt;68.What is better - 2nd Normal form or 3rd normal form? Why?&lt;br /&gt;&lt;br /&gt;69.Can we rewrite subqueries into simple select statements or with joins? Example?&lt;br /&gt;&lt;br /&gt;70.What is a function? Give some example?&lt;br /&gt;&lt;br /&gt;71.What is a stored procedure?&lt;br /&gt;&lt;br /&gt;72.Difference between Function and Procedure-in general?&lt;br /&gt;&lt;br /&gt;73.Difference between Function and Stored Procedure?&lt;br /&gt;&lt;br /&gt;74.Can a stored procedure call another stored procedure. If yes what level and can it be controlled?&lt;br /&gt;&lt;br /&gt;75.Can a stored procedure call itself(recursive). If yes what level and can it be controlled.?&lt;br /&gt;&lt;br /&gt;76.How do you find the number of rows in a table?&lt;br /&gt;&lt;br /&gt;77.Difference between Cluster and Non-cluster index?&lt;br /&gt;&lt;br /&gt;78.What is a table called, if it does not have neither Cluster nor Non-cluster Index?&lt;br /&gt;&lt;br /&gt;79.Explain DBMS, RDBMS?&lt;br /&gt;&lt;br /&gt;80.Explain basic SQL queries with SELECT from where Order By, Group By-Having?&lt;br /&gt;&lt;br /&gt;81.Explain the basic concepts of SQL server architecture?&lt;br /&gt;&lt;br /&gt;82.Explain couple pf features of SQL server&lt;br /&gt;&lt;br /&gt;83.Scalability, Availability, Integration with internet, etc.)?&lt;br /&gt;&lt;br /&gt;84.Explain fundamentals of Data ware housing &amp;amp; OLAP?&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;85.Explain the new features of SQL server 2000?&lt;br /&gt;&lt;br /&gt;86.How do we upgrade from SQL Server 6.5 to 7.0 and 7.0 to 2000?&lt;br /&gt;&lt;br /&gt;87.What is data integrity? Explain constraints?&lt;br /&gt;&lt;br /&gt;88.Explain some DBCC commands?&lt;br /&gt;&lt;br /&gt;89.Explain sp_configure commands, set commands?&lt;br /&gt;&lt;br /&gt;90.Explain what are db_options used for?&lt;br /&gt;&lt;br /&gt;91.What is the basic functions for master, msdb, tempdb databases?&lt;br /&gt;&lt;br /&gt;92.What is a job?&lt;br /&gt;&lt;br /&gt;93.What are tasks?&lt;br /&gt;&lt;br /&gt;94.What are primary keys and foreign keys?&lt;br /&gt;&lt;br /&gt;95.How would you Update the rows which are divisible by 10, given a set of numbers in column?&lt;br /&gt;&lt;br /&gt;96.If a stored procedure is taking a table data type, how it looks?&lt;br /&gt;&lt;br /&gt;97.How m-m relationships are implemented?&lt;br /&gt;&lt;br /&gt;98.How do you know which index a table is using?&lt;br /&gt;&lt;br /&gt;99.How will oyu test the stored procedure taking two parameters namely first name and last name returning full name?&lt;br /&gt;&lt;br /&gt;100.How do you find the error, how can you know the number of rows effected by last SQL statement?&lt;br /&gt;&lt;br /&gt;101.How can you get @@error and @@rowcount at the same time?&lt;br /&gt;&lt;br /&gt;102.What are sub-queries? Give example? In which case sub-queries are not feasible?&lt;br /&gt;&lt;br /&gt;103.What are the type of joins? When do we use Outer and Self joins?&lt;br /&gt;&lt;br /&gt;104.Which virtual table does a trigger use?&lt;br /&gt;&lt;br /&gt;105.How do you measure the performance of a stored procedure?&lt;br /&gt;&lt;br /&gt;106.Questions regarding Raiseerror?&lt;br /&gt;&lt;br /&gt;107.Questions on identity?&lt;br /&gt;&lt;br /&gt;108.If there is failure during updation of certain rows, what will be the state?  &lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&gt;&gt;&gt;Next&gt;&gt;&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2967271806809978211-6471824363687037982?l=oracledbs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracledbs.blogspot.com/feeds/6471824363687037982/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2967271806809978211&amp;postID=6471824363687037982' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/6471824363687037982'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/6471824363687037982'/><link rel='alternate' type='text/html' href='http://oracledbs.blogspot.com/2008/02/interview-questions_4522.html' title='Interview Questions'/><author><name>Real Time Scenario</name><uri>http://www.blogger.com/profile/11930020132547308855</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2967271806809978211.post-8106769804792811668</id><published>2008-02-08T04:47:00.000-08:00</published><updated>2008-02-08T04:54:21.498-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Interview Questions-4'/><title type='text'>Interview Questions</title><content type='html'>&lt;div style="text-align: center;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&gt;&gt;Previous&gt;&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;31.What are the authentication modes in SQL Server?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;- Windows mode and mixed mode (SQL &amp;amp; Windows).&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;32.Where do you think the users names and passwords will be stored in sql server? &lt;/span&gt;&lt;br /&gt;- They get stored in master db in the sysxlogins table.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;33.What is log shipping? &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Can we do logshipping with SQL Server 7.0 - Logshipping is a new feature of SQL Server 2000. We should have two SQL Server - Enterprise Editions. From Enterprise Manager we can configure the logshipping. In logshipping the transactional log file from one server is automatically updated into the backup database on the other server. If one server fails, the other server will have the same db and we can use this as the DR (disaster recovery) plan.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;34.Let us say the SQL Server crashed and you are rebuilding the databases including the master database what procedure to you follow?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;- For restoring the master db we have to stop the SQL Server first and then from command line we can type SQLSERVER –m which will basically bring it into the maintenance mode after which we can restore the master db.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;35.Let us say master db itself has no backup. Now you have to rebuild the db so what kind of action do you take?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;- (I am not sure- but I think we have a command to do it).&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;36.What is BCP? When do we use it?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;- BulkCopy is a tool used to copy huge amount of data from tables and views. But it won’t copy the structures of the same.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;37.What should we do to copy the tables, schema and views from one SQL Server to another? &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;- We have to write some DTS packages for it.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;38.What are the different types of joins and what dies each do?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;39.What are the four main query statements?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;40.What is a sub-query? When would you use one?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;41.What is a NOLOCK?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;42.What are three SQL keywords used to change or set someone’s permissions?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;43.What is the difference between HAVING clause and the WHERE clause?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;44.What is referential integrity? What are the advantages of it?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;45.What is database normalization?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;46.Which command using Query Analyzer will give you the version of SQL server and operating system?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;47.Using query analyzer, name 3 ways you can get an accurate count of the number of records in a table?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;48.What is the purpose of using COLLATE in a query?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;49.What is a trigger? &lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:&amp;quot;;font-size:100%;"  &gt;&lt;span style="font-weight: bold;"&gt;50.What is one of the first things you would do to increase performance of a query?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;div style="text-align: center;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:&amp;quot;;" &gt;&lt;span style="font-weight: bold;"&gt;&gt;&gt;&gt;Next&gt;&gt;&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2967271806809978211-8106769804792811668?l=oracledbs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracledbs.blogspot.com/feeds/8106769804792811668/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2967271806809978211&amp;postID=8106769804792811668' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/8106769804792811668'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/8106769804792811668'/><link rel='alternate' type='text/html' href='http://oracledbs.blogspot.com/2008/02/interview-questions_9255.html' title='Interview Questions'/><author><name>Real Time Scenario</name><uri>http://www.blogger.com/profile/11930020132547308855</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2967271806809978211.post-3481627853068121039</id><published>2008-02-08T04:33:00.000-08:00</published><updated>2008-02-08T04:47:25.185-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Interview Questions-3'/><title type='text'>Interview Questions</title><content type='html'>&lt;div style="text-align: center;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;br /&gt;&gt;&gt;Previous&gt;&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;21.What is a Join in SQL Server?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;- Join actually puts data from two or more tables into a single result set.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;22.Can you explain the types of Joins that we can have with Sql Server?&lt;br /&gt;&lt;br /&gt;&lt;/span&gt; - There are three types of joins: Inner Join, Outer Join, Cross Join.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;23.When do you use SQL Profiler?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;- SQL Profiler utility allows us to basically track connections to the SQL Server and also determine activities such as which SQL Scripts are running, failed jobs etc..&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;24.What is a Linked Server?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;- Linked Servers is a concept in SQL Server by which we can add other SQL Server to a Group and query both the SQL Server dbs using T-SQL Statements.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;25.Can you link only other SQL Servers or any database servers such as Oracle?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;- We can link any server provided we have the OLE-DB provider from Microsoft to allow a link. For Oracle we have a OLE-DB provider for oracle that microsoft provides to add it as a linked server to the sql server group.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;26.Which stored procedure will you be running to add a linked server?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;- sp_addlinkedserver, sp_addlinkedsrvlogin&lt;p class="MsoNormal" style="margin-left: 0.25in;"&gt; &lt;/p&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;27.What are the OS services that the SQL Server installation adds?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;- MS SQL SERVER SERVICE, SQL AGENT SERVICE, DTC (Distribution transac co-ordinator)&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;28.Can you explain the role of each service?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;- SQL SERVER - is for running the databases SQL AGENT - is for automation such as Jobs, DB Maintanance, Backups DTC - Is for linking and connecting to other SQL Servers.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;29.How do you troubleshoot SQL Server if its running very slow?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;- First check the processor and memory usage to see that processor is not above 80% utilization and memory not above 40-45% utilization then check the disk utilization using Performance Monitor, Secondly, use SQL Profiler to check for the users and current SQL activities and jobs running which might be a problem. Third would be to run UPDATE_STATISTICS command to update the indexes.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:&amp;quot;;font-size:100%;"  &gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;30.Lets say due to N/W or Security issues client is not able to connect to server or vice versa. How do you troubleshoot? &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;- First I will look to ensure that port settings are proper on server and client Network utility for connections. ODBC is properly configured at client end for connection ——Makepipe &amp;amp; readpipe are utilities to check for connection. Makepipe is run on Server and readpipe on client to check for any connection issues. &lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;div style="text-align: center;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&gt;&gt;&gt;Next&gt;&gt;&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2967271806809978211-3481627853068121039?l=oracledbs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracledbs.blogspot.com/feeds/3481627853068121039/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2967271806809978211&amp;postID=3481627853068121039' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/3481627853068121039'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/3481627853068121039'/><link rel='alternate' type='text/html' href='http://oracledbs.blogspot.com/2008/02/interview-questions_1107.html' title='Interview Questions'/><author><name>Real Time Scenario</name><uri>http://www.blogger.com/profile/11930020132547308855</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2967271806809978211.post-5252087654539492557</id><published>2008-02-08T04:28:00.000-08:00</published><updated>2008-02-08T04:31:53.817-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Interview Questions-2'/><title type='text'>Interview Questions</title><content type='html'>&lt;div style="text-align: center;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&gt;&gt;Previous&gt;&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;11.Which TCP/IP port does SQL Server run on?&lt;/span&gt; - SQL Server runs on port 1433 but we can also change it for better security. &lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;12.From where can you change the default port?&lt;/span&gt; - From the Network Utility TCP/IP properties –&gt; Port number.both on client and the server. &lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;13.Can you tell me the difference between DELETE &amp;amp; TRUNCATE commands? &lt;/span&gt;- Delete command removes the rows from a table based on the condition that we provide with a WHERE clause. Truncate will actually remove all the rows from a table and there will be no data in the table after we run the truncate command. &lt;o:p&gt;&lt;/o:p&gt;&lt;span style=""&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;14.Can we use Truncate command on a table which is referenced by FOREIGN KEY?&lt;/span&gt; - No. We cannot use Truncate command on a table with Foreign Key because of referential integrity.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;15.What is the use of DBCC commands?&lt;/span&gt; - DBCC stands for database consistency checker. We use these commands to check the consistency of the databases, i.e., maintenance, validation task and status checks. &lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;16.Can you give me some DBCC command options?&lt;/span&gt;(Database consistency check) - DBCC CHECKDB - Ensures that tables in the db and the indexes are correctly linked.and DBCC CHECKALLOC - To check that all pages in a db are correctly allocated. DBCC SQLPERF - It gives report on current usage of transaction log in percentage. DBCC CHECKFILEGROUP - Checks all tables file group for any damage. &lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;17.What command do we use to rename a db? &lt;/span&gt;- sp_renamedb ‘oldname’ , ‘newname’ &lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;18.Well sometimes sp_reanmedb may not work you know because if some one is using the db it will not accept this command so what do you think you can do in such cases?&lt;/span&gt; - In such cases we can first bring to db to single user using sp_dboptions and then we can rename that db and then we can rerun the sp_dboptions command to remove the single user mode. &lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;19.What is the difference between a HAVING CLAUSE and a WHERE CLAUSE?&lt;/span&gt; - Having Clause is basically used only with the GROUP BY function in a query. WHERE Clause is applied to each row before they are part of the GROUP BY function in a query. &lt;o:p&gt;&lt;/o:p&gt;  &lt;span style="font-size: 12pt; font-family: &amp;quot;Times New Roman&amp;quot;;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;20.What do you mean by COLLATION?&lt;/span&gt; - Collation is basically the sort order. There are three types of sort order Dictionary case sensitive, Dictonary - case insensitive and Binary.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;div style="text-align: center;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 12pt; font-family: &amp;quot;Times New Roman&amp;quot;;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&gt;&gt;&gt;Next&gt;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: 12pt; font-family: &amp;quot;Times New Roman&amp;quot;;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2967271806809978211-5252087654539492557?l=oracledbs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracledbs.blogspot.com/feeds/5252087654539492557/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2967271806809978211&amp;postID=5252087654539492557' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/5252087654539492557'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/5252087654539492557'/><link rel='alternate' type='text/html' href='http://oracledbs.blogspot.com/2008/02/interview-questions_08.html' title='Interview Questions'/><author><name>Real Time Scenario</name><uri>http://www.blogger.com/profile/11930020132547308855</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2967271806809978211.post-7400449325796128560</id><published>2008-02-08T04:13:00.000-08:00</published><updated>2008-02-08T04:28:07.966-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Interview Questions-1'/><title type='text'>Interview Questions</title><content type='html'>&lt;div style="text-align: center;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;br /&gt;&gt;&gt;Previous&gt;&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;1.What is normalization?&lt;/span&gt; - Well a relational database is basically composed of tables that contain related data. So the Process of organizing this data into tables is actually referred to as normalization. &lt;span style=";font-family:&amp;quot;;" &gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;2.What is a Stored Procedure?&lt;/span&gt; - Its nothing but a set of T-SQL statements combined to perform a single task of several tasks. Its basically like a Macro so when you invoke the Stored procedure, you actually run a set of statements. &lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;3.Can you give an example of Stored Procedure?&lt;/span&gt; - sp_helpdb , sp_who2, sp_renamedb are a set of system defined stored procedures. We can also have user defined stored procedures which can be called in similar way. &lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;4.What is a trigger? &lt;/span&gt;- Triggers are basically used to implement business rules. Triggers is also similar to stored procedures. The difference is that it can be activated when data is added or edited or deleted from a table in a database. &lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;5.What is a view? &lt;/span&gt;- If we have several tables in a db and we want to view only specific columns from specific tables we can go for views. It would also suffice the needs of security some times allowing specfic users to see only specific columns based on the permission that we can configure on the view. Views also reduce the effort that is required for writing queries to access specific columns every time. &lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;6.What is an Index?&lt;/span&gt; - When queries are run against a db, an index on that db basically helps in the way the data is sorted to process the query for faster and data retrievals are much faster when we have an index. &lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;7.What are the types of indexes available with SQL Server?&lt;/span&gt; - There are basically two types of indexes that we use with the SQL Server. Clustered and the Non-Clustered. &lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;8.What is the basic difference between clustered and a non-clustered index?&lt;/span&gt; - The difference is that, Clustered index is unique for any given table and we can have only one clustered index on a table. The leaf level of a clustered index is the actual data and the data is resorted in case of clustered index. Whereas in case of non-clustered index the leaf level is actually a pointer to the data in rows so we can have as many non-clustered indexes as we can on the db. &lt;span style="font-size:100%;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;  &lt;span style=";font-family:&amp;quot;;font-size:100%;"  &gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:100%;" &gt;9.What are cursors? -&lt;/span&gt;&lt;span style="font-size:100%;"&gt; Well cursors help us to do an operation on a set of data that we retreive by commands such as Select columns from table. For example : If we have duplicate records in a table we can remove it by declaring a cursor which would check the records during retreival one by one and remove rows which have duplicate values.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=";font-family:&amp;quot;;font-size:100%;"  &gt;&lt;span style="font-weight: bold;"&gt;10. When do we use the UPDATE_STATISTICS command? &lt;/span&gt;- This command is basically used when we do a large processing of data. If we do a large amount of deletions any modification or Bulk Copy into the tables, we need to basically update the indexes to take these changes into account. UPDATE_STATISTICS updates the indexes on these tables accordingly.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;div style="text-align: center;"&gt;&lt;span style=";font-family:&amp;quot;;font-size:12;"  &gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size:100%;"&gt;&gt;&gt;&gt;Next&gt;&gt;&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=";font-family:&amp;quot;;font-size:12;"  &gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2967271806809978211-7400449325796128560?l=oracledbs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracledbs.blogspot.com/feeds/7400449325796128560/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2967271806809978211&amp;postID=7400449325796128560' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/7400449325796128560'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/7400449325796128560'/><link rel='alternate' type='text/html' href='http://oracledbs.blogspot.com/2008/02/interview-questions.html' title='Interview Questions'/><author><name>Real Time Scenario</name><uri>http://www.blogger.com/profile/11930020132547308855</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2967271806809978211.post-9155514477171694679</id><published>2008-02-08T04:03:00.000-08:00</published><updated>2008-02-08T04:12:19.657-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SELECT INTO'/><title type='text'>SQL Server</title><content type='html'>&lt;p class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;span style=";font-family:Verdana;font-size:7;"  &gt;&lt;span style="font-size:180%;"&gt;&lt;b style="color: rgb(153, 0, 0);"&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;span style=";font-family:Verdana;font-size:7;"  &gt;&lt;span style="font-size:180%;"&gt;&lt;b style="color: rgb(153, 0, 0);"&gt;SELECT INTO&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;span style=";font-family:Verdana;font-size:7;"  &gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;span style=";font-family:Verdana;font-size:7;"  &gt;&lt;span style="font-size:100%;"&gt;The &lt;b&gt;SELECT INTO &lt;/b&gt;statement enables one to create  new table based on query results.&lt;br /&gt;&lt;br /&gt;One can create both &lt;b&gt;temporary&lt;/b&gt;  and &lt;b&gt;permanent tables&lt;/b&gt; using SELECT INTO.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;span style=";font-family:Verdana;font-size:7;"  &gt;&lt;span style="font-size:100%;"&gt;&lt;a href="http://oracledbs.blogspot.com/"&gt;&lt;span style="font-weight: bold; font-style: italic;"&gt;Syntax:&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;SELECT  column_list&lt;br /&gt;INTO new_table_name&lt;br /&gt;FROM table_list&lt;br /&gt;WHERE  search_condition&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(153, 51, 0);"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;span style=";font-family:Verdana;font-size:7;"  &gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-weight: bold; color: rgb(153, 51, 0);"&gt;Example:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;SELECT * into mystores&lt;br /&gt;FROM  Stores&lt;br /&gt;Go&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; font-style: italic;"&gt;OR&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;SELECT title_id, title&lt;br /&gt;INTO #tmptables&lt;br /&gt;FROM  titles&lt;br /&gt;Go&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;span style=";font-family:Verdana;font-size:7;"  &gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;span style="font-size:100%;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;ul type="disc"&gt;&lt;li class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:Verdana;" &gt;When Creating permanent tables  using select into, one must set the SELECT INTO/BULK COPY database option  true.&lt;br /&gt;&lt;br /&gt;[sp_dboption 'pubs', 'select into/bulkcopy', true]&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;ul type="disc"&gt;&lt;li class="MsoNormal" style=""&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:Verdana;" &gt;Name of the new table must be  &lt;b&gt;unique&lt;/b&gt; within the database and must conform to the rules for SQL Server  naming conventions.&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;ul type="disc"&gt;&lt;li class="MsoNormal" style=""&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:Verdana;" &gt;When creating &lt;b&gt;local temporary  table&lt;/b&gt; (Local temporary table are those that are available only during the  current user session to SQL Server and are delocated when the session is  terminated) use in front of new table name.&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;ul type="disc"&gt;&lt;li class="MsoNormal" style=""&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:Verdana;" &gt;When creating global &lt;b&gt;temporary  table&lt;/b&gt; (Available to all user sessions to SQL Server and are deallocated when  the last user session accessing the table is terminated) use ## in front of new  table name.&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;div style="text-align: center;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="font-size:100%;"&gt;&gt;&gt;&gt;Next&gt;&gt;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2967271806809978211-9155514477171694679?l=oracledbs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracledbs.blogspot.com/feeds/9155514477171694679/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2967271806809978211&amp;postID=9155514477171694679' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/9155514477171694679'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/9155514477171694679'/><link rel='alternate' type='text/html' href='http://oracledbs.blogspot.com/2008/02/sql-server_1224.html' title='SQL Server'/><author><name>Real Time Scenario</name><uri>http://www.blogger.com/profile/11930020132547308855</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2967271806809978211.post-666123846313842144</id><published>2008-02-08T03:45:00.001-08:00</published><updated>2008-02-08T04:03:13.742-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Sub Queries'/><title type='text'></title><content type='html'>&lt;div style="text-align: center;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&gt;&gt;Previous&gt;&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;b style="color: rgb(153, 0, 0);"&gt;SubQueries&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;A Select statement within another SELECT, INSERT,  UPDATE or DELETE statement. Subqueries can produce the same results as  Joins. But Subqueries are more recommandable than Joins and will take less IO cycles than joins.,&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(153, 51, 0);"&gt;&lt;br /&gt;Remember:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;1) One can have as many nested subqueries in one as one want, there is no limit on  this.&lt;br /&gt;&lt;br /&gt;2) The subquery is always enclosed in parentheses unless used in Update statement.&lt;br /&gt;&lt;br /&gt;3) Subquery can not contain an Order By, Compute, or SELECT INTO Clause ie in Where list!!&lt;br /&gt;&lt;br /&gt;4)  Subquery can not be used in the Order By clause.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;span style=";font-family:Verdana;font-size:7;"  &gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-weight: bold; color: rgb(153, 0, 0);"&gt;Example:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;span style=";font-family:Verdana;font-size:7;"  &gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;br /&gt;Sql&gt; SELECT distinct au_fname,au_lname, state&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;span style=";font-family:Verdana;font-size:7;"  &gt;&lt;span style="font-size:100%;"&gt;FROM authors where  state IN&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;span style=";font-family:Verdana;font-size:7;"  &gt;&lt;span style="font-size:100%;"&gt;(SELECT state from stores);&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;span style=";font-family:Verdana;font-size:7;"  &gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;br /&gt;&lt;span style=";font-family:Verdana;font-size:7;"  &gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin-bottom: 12pt; text-align: center;"&gt;&lt;span style=";font-family:Verdana;font-size:7;"  &gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-weight: bold;"&gt;&gt;&gt;&gt;Next&gt;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin-bottom: 12pt; text-align: center;"&gt;&lt;br /&gt;&lt;span style=";font-family:Verdana;font-size:7;"  &gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin-bottom: 12pt; text-align: center;"&gt;&lt;span style=";font-family:Verdana;font-size:7;"  &gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2967271806809978211-666123846313842144?l=oracledbs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracledbs.blogspot.com/feeds/666123846313842144/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2967271806809978211&amp;postID=666123846313842144' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/666123846313842144'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/666123846313842144'/><link rel='alternate' type='text/html' href='http://oracledbs.blogspot.com/2008/02/subqueries-select-statement-within.html' title=''/><author><name>Real Time Scenario</name><uri>http://www.blogger.com/profile/11930020132547308855</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2967271806809978211.post-8376430212962358109</id><published>2008-02-08T03:42:00.001-08:00</published><updated>2008-02-08T03:44:54.082-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Implementing Joins-2'/><title type='text'>SQL Server</title><content type='html'>&lt;div style="text-align: center;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&gt;&gt;Previous&gt;&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;a href="http://oracledbs.blogspot.com/"&gt;&lt;span style="font-weight: bold; color: rgb(0, 102, 0);"&gt;Cross Join or Unrestricted Join&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Returns combination of all rows of all tables in join as the result set. Each row of one table is joined with each row of another table.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(153, 0, 0);"&gt;Example:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;SQL  Server syntax&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;SELECT p.pub_name, p1.pr_info&lt;br /&gt;FROM publishers p,  pub_info p1&lt;br /&gt;&lt;br /&gt;&lt;b&gt;ANSI syntax&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;SELECT  p.pub_name,p1.pr_info&lt;br /&gt;FROM publishers p CROSS JOIN pub_info  p1&lt;br /&gt;&lt;br /&gt;&lt;b style="color: rgb(153, 0, 0);"&gt;&lt;br /&gt;Outer Join&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Restricts rows from one table while allowing  all rows from another table as a result set. Usually used for orphan  records.&lt;br /&gt;&lt;br /&gt;Outer joins. Outer joins can be a left, right, or full outer join. Outer joins are specified with one of the following sets of keywords when they are specified in the FROM clause:&lt;br /&gt;&lt;br /&gt;&lt;b style="color: rgb(153, 51, 0);"&gt;&lt;br /&gt;LEFT JOIN or LEFT OUTER  JOIN&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;The result set of a left outer join includes all the rows from the left table specified in the LEFT OUTER clause, not just the ones in which the joined columns match. When a row in the left table has no matching rows in the right table, the associated result set row contains null values for all select list columns coming from the right table.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(153, 0, 0);"&gt;Example:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;USE  pubs&lt;br /&gt;SELECT a.au_fname, a.au_lname, p.pub_name&lt;br /&gt;FROM authors a LEFT OUTER  JOIN publishers p&lt;br /&gt;ON a.city = p.city&lt;br /&gt;ORDER BY p.pub_name ASC, a.au_lname  ASC, a.au_fname ASC&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 102, 0);"&gt;Note:&lt;/span&gt;If Inner Join were used in above query then we would have got only the results of authors name whose city was same as publishers and not those authors who lived in city to which no publisher belonged to. In this case we got name of all the authors.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;b style="color: rgb(153, 0, 0);"&gt;Self Join&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Correlates rows of a table with other rows in the same  table.&lt;br /&gt;&lt;br /&gt;A table can be joined to itself in a Self Join. For example, you  can use a Self Join to find out the authors in Oakland, California who live in  the same zip code area.&lt;br /&gt;&lt;br /&gt;Because this query involves a Join of the authors  table with itself&lt;br /&gt;&lt;br /&gt;USE pubs&lt;br /&gt;&lt;br /&gt;SELECT au1.au_fname, au1.au_lname,  au2.au_fname, au2.au_lname&lt;br /&gt;FROM authors au1 INNER join authors au2&lt;br /&gt;ON  au1.zip = au2.zip&lt;br /&gt;WHERE au1.city = 'Oakland'&lt;br /&gt;AND au1.state = 'CA'&lt;br /&gt;AND  au1.au_id &lt; au2.au_id&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;span style="font-weight: bold;"&gt;&gt;&gt;&gt;Next&gt;&gt;&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2967271806809978211-8376430212962358109?l=oracledbs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracledbs.blogspot.com/feeds/8376430212962358109/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2967271806809978211&amp;postID=8376430212962358109' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/8376430212962358109'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/8376430212962358109'/><link rel='alternate' type='text/html' href='http://oracledbs.blogspot.com/2008/02/sql-server_6588.html' title='SQL Server'/><author><name>Real Time Scenario</name><uri>http://www.blogger.com/profile/11930020132547308855</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2967271806809978211.post-801806081959050654</id><published>2008-02-08T03:24:00.001-08:00</published><updated>2008-02-08T03:42:09.364-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Implementing Joins-1'/><title type='text'>SQL Server</title><content type='html'>&lt;div style="text-align: center;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&gt;&gt;Previous&gt;&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;b style="color: rgb(153, 0, 0);"&gt;Implementing Joins&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;br /&gt;Joins&lt;/b&gt; are used to retrieve data from two  or more tables. The results appear as a single table with columns from the  entire table specified in the SELECT column_list and meeting the search  criteria. &lt;b&gt;&lt;br /&gt;&lt;br /&gt;In nutshell&lt;/b&gt; Joins connect two or more tables based on a join  condition and produce results as new table with the rows that satisfy the join  condition&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;We will probe Joins using both &lt;b&gt;SQL Server syntax&lt;/b&gt; and  &lt;b&gt;ANSI syntax&lt;/b&gt;.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;br /&gt;Inner Join&lt;/b&gt;: There can be two types of Inner  Joins.&lt;br /&gt;&lt;br /&gt;One is &lt;a href="http://oracledbs.blogspot.com"&gt;&lt;span style="font-weight: bold;"&gt;EquiJoin&lt;/span&gt;&lt;/a&gt; and other is &lt;a href="http://oracledbs.blogspot.com"&gt;&lt;span style="font-weight: bold;"&gt;Natural Join&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Using &lt;b&gt;Pubs&lt;/b&gt;  consider tables:&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;br /&gt;Publishers&lt;/b&gt; (pub_id, pub_name, city, state,  country) Primary Key (pub_id)&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;br /&gt;Pub_info&lt;/b&gt; (pub_id, logo, pr_info)  Primary Key (pub_id)&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;br /&gt;Authors&lt;/b&gt; (au_id, au_lname, au_fname, phone,  address, city, state, zip, contact) Primary Key (au_id)&lt;br /&gt;&lt;br /&gt;&lt;b&gt;EquiJoin&lt;/b&gt;:  In Equi Join Column values are compared for equality and redundant columns are  displayed as columns in the result set&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a style="font-weight: bold;" href="http://oracledbs.blogspot.com/"&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;Example:&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;SQL Server  syntax&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;SELECT *&lt;br /&gt;FROM publishers, pub_info&lt;br /&gt;WHERE  publishers.pub_id=pub_info.pub_id&lt;br /&gt;&lt;br /&gt;&lt;b&gt;ANSI syntax&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;SELECT  *&lt;br /&gt;FROM Publishers&lt;br /&gt;INNER JOIN pub_info ON publishers.pub_id =  pub_info.pub_id&lt;br /&gt;&lt;a href="http://oracledbs.blogspot.com/"&gt;&lt;br /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://oracledbs.blogspot.com/"&gt;&lt;b style="color: rgb(153, 51, 0);"&gt;Natural Join&lt;/b&gt;&lt;span style="color: rgb(153, 51, 0);"&gt;: &lt;/span&gt;&lt;/a&gt;In Natural Joins redundant columns  are not displayed twice&lt;br /&gt;&lt;br /&gt;Example:&lt;br /&gt;&lt;br /&gt;&lt;b style="color: rgb(0, 102, 0);"&gt;SQL Server syntax&lt;/b&gt;&lt;span style="color: rgb(0, 102, 0);"&gt; &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;SELECT  p. *, p1.logo, p1.pr_info&lt;br /&gt;FROM publishers p, pub_info p1&lt;br /&gt;Where p.pub_id =  p1.pub_id&lt;br /&gt;&lt;br /&gt;&lt;b style="color: rgb(0, 102, 0);"&gt;ANSI syntax&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;SELECT p.*, p1.logo,  p1.pr_info&lt;br /&gt;FROM publishers p&lt;br /&gt;INNER JOIN pub_info p1 ON p.pub_id =  p1.pub_id&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&gt;&gt;&gt;Next&gt;&gt;&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2967271806809978211-801806081959050654?l=oracledbs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracledbs.blogspot.com/feeds/801806081959050654/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2967271806809978211&amp;postID=801806081959050654' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/801806081959050654'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/801806081959050654'/><link rel='alternate' type='text/html' href='http://oracledbs.blogspot.com/2008/02/sql-server_2321.html' title='SQL Server'/><author><name>Real Time Scenario</name><uri>http://www.blogger.com/profile/11930020132547308855</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2967271806809978211.post-7744809709486992912</id><published>2008-02-08T01:55:00.000-08:00</published><updated>2008-02-08T02:50:15.568-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Compute By Clause'/><title type='text'>SQL Server</title><content type='html'>&lt;b style="color: rgb(153, 0, 0);"&gt;Compute By Clause&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;The compute and compute by clause are used to  produce new rows of summary and detail data. They use the aggregate functions.  The COMPUTE clause return detail rows and a grand total summary row. The compute  by clause return the new rows of summary data, much like Group By clause, but it  returns the rows as sub-groups with summary values&lt;br /&gt;&lt;br /&gt;One has to use Order  By clause before using Compute By clause&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0); font-weight: bold;"&gt;&lt;br /&gt;Example&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;SELECT type, SUM  (ytd_sales)&lt;br /&gt;FROM titles&lt;br /&gt;ORDER BY type COMPUTE SUM(ytd_sales) BY type&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2967271806809978211-7744809709486992912?l=oracledbs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracledbs.blogspot.com/feeds/7744809709486992912/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2967271806809978211&amp;postID=7744809709486992912' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/7744809709486992912'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/7744809709486992912'/><link rel='alternate' type='text/html' href='http://oracledbs.blogspot.com/2008/02/sql-server_4813.html' title='SQL Server'/><author><name>Real Time Scenario</name><uri>http://www.blogger.com/profile/11930020132547308855</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2967271806809978211.post-5693891153987842964</id><published>2008-02-08T01:39:00.000-08:00</published><updated>2008-02-08T01:52:27.600-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Aggregate Functions with Groupby n Having clause'/><title type='text'>SQL Server</title><content type='html'>&lt;p style="text-align: center;" class="MsoNormal"&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="text-align: center;" class="MsoNormal"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-weight: bold;"&gt;&gt;&gt;Previous&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style="font-size:78%;"&gt;&lt;b&gt;&lt;span style=";font-family:Verdana;" &gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style="color: rgb(102, 0, 0);font-size:100%;" &gt;&lt;b&gt;&lt;span style=";font-family:Verdana;" &gt;Aggregate  Functions&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;&lt;a href="http://oracledbs.blogspot.com/"&gt;&lt;b style="color: rgb(0, 102, 0);"&gt;&lt;br /&gt;Aggregate  functions&lt;/b&gt;&lt;/a&gt; can return summary values for an entire table or for group of rows  in a table. Aggregate functions are usually used in conjunction with the  &lt;b&gt;GROUP BY&lt;/b&gt; clause and are used in&lt;a href="http://oracledbs.blogspot.com/"&gt;&lt;span style="color: rgb(0, 102, 0);"&gt; &lt;/span&gt;&lt;b style="color: rgb(0, 102, 0);"&gt;HAVING&lt;/b&gt;&lt;/a&gt; Clause or in the  column_list.&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;span style=";font-family:Symbol;font-size:100%;"  &gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;span style=";font-family:Symbol;font-size:100%;"  &gt;·&lt;/span&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;&lt;span style=""&gt;   &lt;/span&gt;&lt;b&gt;AVG&lt;/b&gt;: Returns average of the values in the numeric  expression&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;&lt;span style="font-weight: bold; color: rgb(204, 0, 0);"&gt;Example&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;SELECT AVG(ytd_sales)&lt;br /&gt;FROM Titles&lt;o:p&gt;  &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style=";font-family:Symbol;font-size:100%;"  &gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style=";font-family:Symbol;font-size:100%;"  &gt;·&lt;/span&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;&lt;span style=""&gt;   &lt;/span&gt;&lt;b&gt;COUNT(*)&lt;/b&gt;: Returns number of selected  rows&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;&lt;span style="font-weight: bold; color: rgb(153, 0, 0);"&gt;Example&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;SELECT Count(*) from &lt;a href="http://oracledbs.blogspot.com/"&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;employee&lt;/span&gt;&lt;/a&gt; [ Returns total number  of rows in a table] &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style=";font-family:Symbol;font-size:100%;"  &gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style=";font-family:Symbol;font-size:100%;"  &gt;·&lt;/span&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;&lt;span style=""&gt;   &lt;/span&gt;&lt;b&gt;MAX&lt;/b&gt;: Returns highest value in the  expression&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(153, 0, 0);"&gt;Example&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;SELECT MAX(ytd_sales) FROM titles  &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;span style=";font-family:Symbol;font-size:100%;"  &gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;span style=";font-family:Symbol;font-size:100%;"  &gt;·&lt;/span&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;&lt;span style=""&gt;   &lt;/span&gt;&lt;b&gt;MIN&lt;/b&gt;: Returns &lt;a href="http://oracledbs.blogspot.com/"&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;lowest&lt;/span&gt;&lt;/a&gt; value in the  expression&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(153, 0, 0);"&gt;Example&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;SELECT MIN (ytd_sales)&lt;br /&gt;FROM titles&lt;o:p&gt;  &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;span style=";font-family:Symbol;font-size:100%;"  &gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;span style=";font-family:Symbol;font-size:100%;"  &gt;·&lt;/span&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;&lt;span style=""&gt;   &lt;/span&gt;&lt;b&gt;SUM&lt;/b&gt;: Returns &lt;a href="http://oracledbs.blogspot.com/"&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;total&lt;/span&gt;&lt;/a&gt; of values in the numeric  expression&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(204, 0, 0);"&gt;Example&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;SELECT SUM(qty)&lt;br /&gt;FROM sales&lt;o:p&gt;  &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;span style=";font-family:Symbol;font-size:100%;"  &gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;span style=";font-family:Symbol;font-size:100%;"  &gt;·&lt;/span&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;&lt;span style=""&gt;   &lt;/span&gt;&lt;b&gt;TOP n&lt;/b&gt;: Returns the top n values in the result set&lt;br /&gt;&lt;br /&gt;SELECT  TOP 5 * FROM authors&lt;br /&gt;&lt;br /&gt;SELECT TOP 5 * FROM sales where qty&gt;20&lt;o:p&gt;  &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;&lt;br /&gt;&lt;br /&gt;&lt;b style="color: rgb(204, 0, 0);"&gt;Group By and Having  Clause&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;The group by clause summary data that meets the WHERE clause  criteria to be returned as single row. The HAVING clause set the criteria to  determine which rows will be returned by the GROUP BY  clause&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(153, 0, 0);"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;&lt;span style="font-weight: bold; color: rgb(153, 0, 0);"&gt;Example&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;SELECT title_id, count (title_id) as  Number_of_Authors&lt;br /&gt;From Titleauthor&lt;br /&gt;GROUP BY title_id Having count  (title_id)&gt;1&lt;br /&gt;&lt;br /&gt;&lt;a href="http://oracledbs.blogspot.com/"&gt;&lt;span style="font-weight: bold; color: rgb(0, 102, 0);"&gt;OR&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;SELECT title_id,ytd_sales&lt;br /&gt;FROM  Titles&lt;br /&gt;WHERE (ytd_sales&gt;=4000)&lt;br /&gt;GROUP BY title_id,ytd_sales&lt;o:p&gt;  &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;1.&lt;span style="font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:'Times New Roman';" &gt;       &lt;/span&gt;HAVING clause has same effect  on the GROUP BY clause as the WHERE clause has on the SELECT statement.  &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;2.&lt;span style="font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:'Times New Roman';" &gt;       &lt;/span&gt;GROUP BY clause must contain  all nonaggregate columns from the SELECT column_list. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;3.&lt;span style="font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:'Times New Roman';" &gt;       &lt;/span&gt;HAVING clause criteria columns  must return only one value.&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in; text-align: center;"&gt;&lt;span style=";font-family:Verdana;font-size:78%;"  &gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in; text-align: center;"&gt;&lt;span style=";font-family:Verdana;font-size:78%;"  &gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-weight: bold;"&gt;&gt;&gt;&gt;Next&gt;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in; text-align: center;"&gt;&lt;br /&gt;&lt;span style=";font-family:Verdana;font-size:78%;"  &gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in; text-align: center;"&gt;&lt;span style=";font-family:Verdana;font-size:78%;"  &gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2967271806809978211-5693891153987842964?l=oracledbs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracledbs.blogspot.com/feeds/5693891153987842964/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2967271806809978211&amp;postID=5693891153987842964' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/5693891153987842964'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/5693891153987842964'/><link rel='alternate' type='text/html' href='http://oracledbs.blogspot.com/2008/02/sql-server_2917.html' title='SQL Server'/><author><name>Real Time Scenario</name><uri>http://www.blogger.com/profile/11930020132547308855</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2967271806809978211.post-8098813064505201049</id><published>2008-02-08T01:29:00.000-08:00</published><updated>2008-02-08T01:38:49.404-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Combining Search Conditions'/><title type='text'>SQL Server</title><content type='html'>&lt;div style="text-align: center;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&gt;&gt;Previous&gt;&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;b style="color: rgb(153, 0, 0);"&gt;Combining Search Conditions&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;As the previous example demonstrates,  one can combine search conditions. But one need to be cautious when combining  search conditions if one isn't familiar with &lt;a href="http://oracledbs.blogspot.com/"&gt;&lt;b style="font-weight: bold; color: rgb(153, 0, 0);"&gt;Boolean logic&lt;/b&gt;&lt;span style="font-weight: bold; color: rgb(153, 0, 0);"&gt;:&lt;/span&gt;&lt;/a&gt; Don't confuse  the AND and OR conditions.&lt;br /&gt;&lt;br /&gt;Suppose someone say, "Get me a list of all our  authors from Utah and Texas." One knows what one want.&lt;br /&gt;&lt;br /&gt;But if one write the  &lt;a href="http://oracledbs.blogspot.com/"&gt;&lt;span style="font-weight: bold; color: rgb(153, 51, 0);"&gt;query&lt;/span&gt;&lt;/a&gt; as---&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;SELECT au_fname, au_lname, phone, au_id&lt;br /&gt;FROM authors&lt;br /&gt;WHERE  state LIKE 'ut' AND state LIKE 'tx'&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The query will not return any data  because it asked for all authors who live in both Utah and Texas. The result you  want is data that meets both conditions, authors who live in either Utah or  Texas.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Instead, use this &lt;a href="http://oracledbs.blogspot.com/"&gt;&lt;span style="color: rgb(153, 51, 0);"&gt;query&lt;/span&gt;&lt;/a&gt;:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;SELECT au_fname, au_lname, phone,  au_id&lt;br /&gt;FROM authors&lt;br /&gt;WHERE state LIKE 'ut' OR state LIKE 'tx'&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://oracledbs.blogspot.com/"&gt;&lt;span style="font-weight: bold; color: rgb(153, 51, 0);"&gt;Note&lt;/span&gt;&lt;/a&gt; that one needs to repeat the search condition. One can't write WHERE state  LIKE 'ut' &lt;a href="http://oracledbs.blogspot.com/"&gt;&lt;span style="font-style: italic; font-weight: bold; color: rgb(153, 51, 0);"&gt;OR&lt;/span&gt;&lt;/a&gt; 'tx' because SQL Server expects a complete search condition on  either side of the OR.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;span style="font-weight: bold;"&gt;&gt;&gt;&gt;Next&gt;&gt;&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2967271806809978211-8098813064505201049?l=oracledbs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracledbs.blogspot.com/feeds/8098813064505201049/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2967271806809978211&amp;postID=8098813064505201049' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/8098813064505201049'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/8098813064505201049'/><link rel='alternate' type='text/html' href='http://oracledbs.blogspot.com/2008/02/sql-server_2103.html' title='SQL Server'/><author><name>Real Time Scenario</name><uri>http://www.blogger.com/profile/11930020132547308855</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2967271806809978211.post-2878163849090681906</id><published>2008-02-08T00:47:00.000-08:00</published><updated>2008-02-08T00:53:49.226-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Distinct n order by'/><title type='text'>SQL Server</title><content type='html'>&lt;p style="text-align: center;" class="MsoNormal"&gt;&lt;span style=";font-family:Verdana;font-size:78%;"  &gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="text-align: center;" class="MsoNormal"&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;&lt;b&gt;&gt;&gt;Previous&gt;&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style=";font-family:Verdana;font-size:78%;"  &gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style=";font-family:Verdana;font-size:78%;"  &gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size:130%;"&gt;&lt;b style="color: rgb(153, 0, 0);"&gt;Using Distinct to Eliminate duplicate  Information&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style=";font-family:Verdana;font-size:78%;"  &gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;One can eliminate duplicates using &lt;a href="http://oracledbs.blogspot.com/"&gt;&lt;b style="color: rgb(153, 51, 0);"&gt;Distinct&lt;/b&gt;&lt;/a&gt;  keyword in the SELECT clause&lt;br /&gt;&lt;br /&gt;SELECT DISTINCT column_list FROM  table_Name&lt;br /&gt;Where search_condition&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(153, 0, 0);"&gt;Example&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;SELECT DISTINCT  city&lt;br /&gt;FROM authors&lt;br /&gt;&lt;br /&gt;&lt;a href="http://oracledbs.blogspot.com/"&gt;&lt;span style="font-weight: bold; font-style: italic; color: rgb(153, 0, 0);"&gt;OR&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;SELECT DISTINCT city, state&lt;br /&gt;FROM  authors&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=";font-family:Verdana;font-size:78%;"  &gt;&lt;span style="font-size:130%;"&gt;&lt;b style="color: rgb(153, 0, 0);"&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style=";font-family:Verdana;font-size:78%;"  &gt;&lt;span style="font-size:130%;"&gt;&lt;b style="color: rgb(153, 0, 0);"&gt;Using ORDER BY clause&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style=";font-family:Verdana;font-size:78%;"  &gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:100%;"&gt;&lt;b&gt;ORDER BY&lt;/b&gt; clause is  used in SELECT statement to sort data&lt;br /&gt;&lt;br /&gt;SELECT column_name&lt;br /&gt;From  Table_List&lt;br /&gt;[order by column_name[&lt;b&gt;ASC|DES&lt;/b&gt;]]&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style=";font-family:Verdana;font-size:78%;"  &gt;&lt;span style="font-size:100%;"&gt;&lt;a href="http://oracledbs.blogspot.com/"&gt;&lt;span style="font-weight: bold; color: rgb(153, 0, 0);"&gt;Example&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;SELECT  title_id, au_id&lt;br /&gt;FROM titleauthor&lt;br /&gt;ORDER BY title_id, au_id&lt;o:p&gt;  &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;ul type="disc"&gt;&lt;li class="MsoNormal" style=""&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;Default Order is Ascending  &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt; &lt;/li&gt;&lt;li class="MsoNormal" style=""&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;Since sort order being used by  &lt;a href="http://oracledbs.blogspot.com/"&gt;&lt;span style="color: rgb(153, 0, 0); font-weight: bold; font-style: italic;"&gt;SQL Server&lt;/span&gt;&lt;/a&gt; can make difference in the ORDER BY clause, one should check default  sort order of SQL Server using sp_helpsort &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt; &lt;/li&gt;&lt;li class="MsoNormal" style=""&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;&lt;a href="http://oracledbs.blogspot.com/"&gt;&lt;span style="font-weight: bold; font-style: italic;"&gt;ORDER BY&lt;/span&gt;&lt;/a&gt; clause can not be used  on text or image columns &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;   &lt;p class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(153, 51, 0);"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;&lt;span style="font-weight: bold; color: rgb(153, 51, 0);"&gt;SQL &lt;/span&gt;&lt;b style="font-weight: bold; color: rgb(153, 51, 0);"&gt;Order of Logical  Operations &lt;/b&gt;&lt;span style="font-weight: bold; color: rgb(153, 51, 0);"&gt;(each operates from left to  right)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;NOT&lt;br /&gt;AND&lt;br /&gt;OR&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin-bottom: 12pt; text-align: center;"&gt;&lt;span style=";font-family:Verdana;font-size:78%;"  &gt;&lt;b&gt;&lt;span style="font-size:100%;"&gt;&gt;&gt;&gt;Next&gt;&gt;&gt;&lt;/span&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2967271806809978211-2878163849090681906?l=oracledbs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracledbs.blogspot.com/feeds/2878163849090681906/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2967271806809978211&amp;postID=2878163849090681906' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/2878163849090681906'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/2878163849090681906'/><link rel='alternate' type='text/html' href='http://oracledbs.blogspot.com/2008/02/sql-server_08.html' title='SQL Server'/><author><name>Real Time Scenario</name><uri>http://www.blogger.com/profile/11930020132547308855</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2967271806809978211.post-5015511044961620603</id><published>2008-02-08T00:38:00.000-08:00</published><updated>2008-02-08T00:46:36.170-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Like n Null'/><title type='text'></title><content type='html'>&lt;div style="text-align: center;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&gt;&gt;Previous&gt;&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;p class="MsoNormal"&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;&lt;span style="font-size:130%;"&gt;&lt;a href="http://oracledbs.blogspot.com"&gt;&lt;span style="font-weight: bold; color: rgb(153, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;&lt;span style="font-size:130%;"&gt;&lt;a href="http://oracledbs.blogspot.com"&gt;&lt;span style="font-weight: bold; color: rgb(153, 0, 0);"&gt;LIKE&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Like is used with character and date  data&lt;br /&gt;&lt;br /&gt;SELECT column_name&lt;br /&gt;FROM table_name&lt;br /&gt;WHERE column_name [NOT]  Like 'string'&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;&lt;a href="http://oracledbs.blogspot.com"&gt;&lt;b style="color: rgb(153, 0, 0);"&gt;Wildcards&lt;/b&gt;&lt;/a&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;1.&lt;span style="font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:'Times New Roman';" &gt;       &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;b&gt;&lt;span style=";font-family:Verdana;" &gt;%&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;- String of zero or more  characters &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;2.&lt;span style="font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:'Times New Roman';" &gt;       &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;b&gt;&lt;span style=";font-family:Verdana;" &gt;_&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt; -Single Character  &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;3.&lt;span style="font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:'Times New Roman';" &gt;       &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;b&gt;&lt;span style=";font-family:Verdana;" &gt;[]&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;- Single character within  specified range &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;4.&lt;span style="font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:'Times New Roman';" &gt;       &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;b&gt;&lt;span style=";font-family:Verdana;" &gt;[^]&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;- Single character not within  specified range &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;  Wildcard characters when used  with Like keyword are enclosed in a single quotation  mark&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;&lt;span style="font-weight: bold; color: rgb(102, 0, 0);"&gt;Example&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;SELECT title_id, title&lt;br /&gt;FROM titles&lt;br /&gt;WHERE title  LIKE '%computers%'&lt;br /&gt;&lt;br /&gt;OR&lt;br /&gt;&lt;br /&gt;SELECT lname&lt;br /&gt;FROM employee&lt;br /&gt;WHERE lname  like 'a%'&lt;br /&gt;&lt;br /&gt;OR&lt;br /&gt;&lt;br /&gt;SELECT lname&lt;br /&gt;FROM employee&lt;br /&gt;WHERE lname like  '%a%'&lt;br /&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;OR&lt;br /&gt;&lt;br /&gt;SELECT lname&lt;br /&gt;FROM employee&lt;br /&gt;WHERE lname like  '%a'&lt;br /&gt;&lt;br /&gt;OR&lt;br /&gt;&lt;br /&gt;SELECT title_id, title&lt;br /&gt;FROM titles&lt;br /&gt;WHERE title LIKE  '[cdefi]%'&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;&lt;b style="color: rgb(153, 0, 0);"&gt;Unknown Values&lt;/b&gt;&lt;br /&gt;&lt;br /&gt; Null is equivalent to value  "&lt;a href="http://oracledbs.blogspot.com"&gt;unknown&lt;/a&gt;"&lt;br /&gt;&lt;br /&gt; IS NULL and IS NOT NULL operators are used&lt;br /&gt;&lt;br /&gt;SELECT  column_list&lt;br /&gt;FROM table_list&lt;br /&gt;WHERE column_name IS [NOT]  NULL&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(153, 51, 0);"&gt;Example&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;SELECT title_id, title&lt;br /&gt;FROM titles&lt;br /&gt;WHERE  title_id IS NOT NULL&lt;br /&gt;&lt;br /&gt;OR&lt;br /&gt;&lt;br /&gt;SELECT title_id, title&lt;br /&gt;FROM  titles&lt;br /&gt;WHERE title_id IS &lt;a href="http://oracledbs.blogspot.com"&gt;&lt;span style="font-weight: bold; color: rgb(153, 0, 0);"&gt;NULL&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;div style="text-align: center;"&gt; &lt;span style="font-weight: bold;"&gt;&gt;&gt;&gt;Next&gt;&gt;&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2967271806809978211-5015511044961620603?l=oracledbs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracledbs.blogspot.com/feeds/5015511044961620603/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2967271806809978211&amp;postID=5015511044961620603' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/5015511044961620603'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/5015511044961620603'/><link rel='alternate' type='text/html' href='http://oracledbs.blogspot.com/2008/02/like-like-is-used-with-character-and.html' title=''/><author><name>Real Time Scenario</name><uri>http://www.blogger.com/profile/11930020132547308855</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2967271806809978211.post-503093104129684215</id><published>2008-02-08T00:22:00.000-08:00</published><updated>2008-02-08T00:36:47.149-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Range and  List operators'/><title type='text'></title><content type='html'>&lt;p style="text-align: center;" class="MsoNormal"&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="text-align: center;" class="MsoNormal"&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;&lt;span style="font-weight: bold;"&gt;&gt;&gt;Previous&gt;&gt;&lt;/span&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;&lt;b style="color: rgb(153, 0, 0);"&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;&lt;span style="font-size:130%;"&gt;&lt;b style="color: rgb(153, 0, 0);"&gt;Comparison Operators&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;One can use comparison operators like  &gt;,&lt;, &gt;=, =&lt;, =, &lt;&gt;, !=, !&gt;, !&lt;,  ()  Example  SELECT emp_id,lname,fname FROM employee WHERE  pub_id='0877'  &lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;&lt;span style="color: rgb(153, 0, 0);font-size:130%;" &gt;&lt;b&gt;Range&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;One can retrieve rows based on a range  of value using the BETWEEN keyword&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Example&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Select lname,  emp_if&lt;br /&gt;FROM Employee&lt;br /&gt;WHERE hire_date between '10/1/92' AND  '12/31/92'&lt;br /&gt;&lt;br /&gt;OR&lt;br /&gt;&lt;br /&gt;Select lname, emp_iD&lt;br /&gt;FROM Employee&lt;br /&gt;WHERE lname  NOT between 'a' AND 'e'&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;Smaller value must come first in  &lt;b&gt;BETWEEN&lt;/b&gt; clause&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;Also one must enclose range in quotes if its  character data types or date data types&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;&lt;span style="color: rgb(153, 0, 0);font-size:130%;" &gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;&lt;span style="color: rgb(153, 0, 0);font-size:130%;" &gt;&lt;span style="font-weight: bold;"&gt;Lists&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;One can use  IN Keyword to match rows in a list&lt;br /&gt;&lt;br /&gt;SELECT Column_list&lt;br /&gt;FROM  table_name&lt;br /&gt;WHERE column_name [NOT] IN (value_list)&lt;br /&gt;Example&lt;br /&gt;&lt;br /&gt;SELECT  emp_id, lname, fname&lt;br /&gt;FROM employee where pub_id IN  ('0877','9990')&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;OR&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;SELECT emp_id, lname, fname, pub_id&lt;br /&gt;FROM  employee where pub_id NOT IN ('0877','9990')&lt;br /&gt;&lt;br /&gt;One can use the NOT  operator to exclude a certain set of data and retrieve the rest. The NOT  operator excludes all records that meet the criteria one  specifies&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="text-align: center;" class="MsoNormal"&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="text-align: center;" class="MsoNormal"&gt;&lt;span style="font-weight: bold;"&gt;&gt;&gt;&gt;Next&gt;&gt;&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="text-align: center;" class="MsoNormal"&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2967271806809978211-503093104129684215?l=oracledbs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracledbs.blogspot.com/feeds/503093104129684215/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2967271806809978211&amp;postID=503093104129684215' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/503093104129684215'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/503093104129684215'/><link rel='alternate' type='text/html' href='http://oracledbs.blogspot.com/2008/02/comparison-operators-example-select.html' title=''/><author><name>Real Time Scenario</name><uri>http://www.blogger.com/profile/11930020132547308855</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2967271806809978211.post-4440276557232764793</id><published>2008-02-07T23:46:00.000-08:00</published><updated>2008-02-08T00:12:03.358-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Date Functions'/><title type='text'>SQL Server</title><content type='html'>&lt;p class="MsoNormal"&gt;&lt;span style="font-size:100%;"&gt;&lt;b&gt;&lt;span style="font-family:Verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style="font-weight: bold; color: rgb(153, 0, 0);font-size:100%;" &gt;&lt;span style="font-family:Verdana;"&gt;Date  Functions&lt;/span&gt;&lt;/span&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;&lt;b style="color: rgb(153, 51, 0);"&gt;Select  date_function(parameter)&lt;/b&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin-bottom: 12pt; margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin-bottom: 12pt; margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;1.&lt;span style="font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:'Times New Roman';" &gt;       &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;b&gt;&lt;span style="font-family:Verdana;"&gt;Dateadd  (datepart,number,date)&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;: Adds the number of dateparts to  the date Example&lt;br /&gt;&lt;br /&gt;Select Dateadd (mm, 6, '1/1/01')-[ 2001-07-01] Select  Dateadd (mm, -6, '1/1/01')-[ 2001-07-01]&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin-bottom: 12pt; margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin-bottom: 12pt; margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;2.&lt;span style="font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:'Times New Roman';" &gt;       &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;b&gt;&lt;span style="font-family:Verdana;"&gt;Datediff  (datepart,date1,date2)&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;: Number of dateparts between two  dates Example&lt;br /&gt;&lt;br /&gt;Select datediff(dd, '10/3/01', '10/9/01')&lt;o:p&gt;  &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin-bottom: 12pt; margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin-bottom: 12pt; margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;3.&lt;span style="font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:'Times New Roman';" &gt;       &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;b&gt;&lt;span style="font-family:Verdana;"&gt;Getdate() &lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;:Returns current date and time in  internal format Example&lt;br /&gt;&lt;br /&gt;Select Getdate()&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin-bottom: 12pt; margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class="MsoNormal" style="margin-bottom: 12pt; margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;&lt;br /&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;div align="center"&gt; &lt;table style="background: rgb(223, 239, 255) none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; margin-left: 0.5in; width: 50%; color: rgb(223, 239, 255);" bg="" border="0" cellpadding="0" width="50%"&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td style="padding: 1.5pt; color: rgb(0, 0, 0);"&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:100%;"&gt;&lt;b&gt;&lt;span style="font-family:Verdana;"&gt;Datepart &lt;/span&gt;&lt;span style="font-family:Verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt; &lt;td style="padding: 1.5pt; color: rgb(0, 0, 0);"&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:100%;"&gt;&lt;b&gt;&lt;span style="font-family:Verdana;"&gt;Abbreviation &lt;/span&gt;&lt;span style="font-family:Verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td style="padding: 1.5pt; color: rgb(0, 0, 0);"&gt; &lt;p class="MsoNormal"&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;Day&lt;/span&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;&lt;o:p&gt;  &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt; &lt;td style="padding: 1.5pt; color: rgb(0, 0, 0);"&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:100%;"&gt;&lt;b&gt;&lt;span style="font-family:Verdana;"&gt;DD,D&lt;/span&gt;&lt;span style="font-family:Verdana;"&gt;&lt;o:p&gt;  &lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td style="padding: 1.5pt; color: rgb(0, 0, 0);"&gt; &lt;p class="MsoNormal"&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;Day of  year&lt;/span&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;&lt;o:p&gt;  &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt; &lt;td style="padding: 1.5pt; color: rgb(0, 0, 0);"&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:100%;"&gt;&lt;b&gt;&lt;span style="font-family:Verdana;"&gt;DY&lt;/span&gt;&lt;span style="font-family:Verdana;"&gt;&lt;o:p&gt;  &lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td style="padding: 1.5pt; color: rgb(0, 0, 0);"&gt; &lt;p class="MsoNormal"&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;Hour&lt;/span&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;&lt;o:p&gt;  &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt; &lt;td style="padding: 1.5pt; color: rgb(0, 0, 0);"&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:100%;"&gt;&lt;b&gt;&lt;span style="font-family:Verdana;"&gt;HH&lt;/span&gt;&lt;span style="font-family:Verdana;"&gt;&lt;o:p&gt;  &lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td style="padding: 1.5pt; color: rgb(0, 0, 0);"&gt; &lt;p class="MsoNormal"&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;Millisecond&lt;/span&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;&lt;o:p&gt;  &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt; &lt;td style="padding: 1.5pt; color: rgb(0, 0, 0);"&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:100%;"&gt;&lt;b&gt;&lt;span style="font-family:Verdana;"&gt;MS&lt;/span&gt;&lt;span style="font-family:Verdana;"&gt;&lt;o:p&gt;  &lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td style="padding: 1.5pt; color: rgb(0, 0, 0);"&gt; &lt;p class="MsoNormal"&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;Minute&lt;/span&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;&lt;o:p&gt;  &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt; &lt;td style="padding: 1.5pt; color: rgb(0, 0, 0);"&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:100%;"&gt;&lt;b&gt;&lt;span style="font-family:Verdana;"&gt;MI&lt;/span&gt;&lt;span style="font-family:Verdana;"&gt;&lt;o:p&gt;  &lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td style="padding: 1.5pt; color: rgb(0, 0, 0);"&gt; &lt;p class="MsoNormal"&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;Month&lt;/span&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;&lt;o:p&gt;  &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt; &lt;td style="padding: 1.5pt; color: rgb(0, 0, 0);"&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:100%;"&gt;&lt;b&gt;&lt;span style="font-family:Verdana;"&gt;MM,M&lt;/span&gt;&lt;span style="font-family:Verdana;"&gt;&lt;o:p&gt;  &lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td style="padding: 1.5pt; color: rgb(0, 0, 0);"&gt; &lt;p class="MsoNormal"&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;Quarter&lt;/span&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;&lt;o:p&gt;  &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt; &lt;td style="padding: 1.5pt; color: rgb(0, 0, 0);"&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:100%;"&gt;&lt;b&gt;&lt;span style="font-family:Verdana;"&gt;QQ&lt;/span&gt;&lt;span style="font-family:Verdana;"&gt;&lt;o:p&gt;  &lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td style="padding: 1.5pt; color: rgb(0, 0, 0);"&gt; &lt;p class="MsoNormal"&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;Second&lt;/span&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;&lt;o:p&gt;  &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt; &lt;td style="padding: 1.5pt; color: rgb(0, 0, 0);"&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:100%;"&gt;&lt;b&gt;&lt;span style="font-family:Verdana;"&gt;SS,  S&lt;/span&gt;&lt;span style="font-family:Verdana;"&gt;&lt;o:p&gt;  &lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td style="padding: 1.5pt; color: rgb(0, 0, 0);"&gt; &lt;p class="MsoNormal"&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;Week&lt;/span&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;&lt;o:p&gt;  &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt; &lt;td style="padding: 1.5pt; color: rgb(0, 0, 0);"&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:100%;"&gt;&lt;b&gt;&lt;span style="font-family:Verdana;"&gt;WK&lt;/span&gt;&lt;span style="font-family:Verdana;"&gt;&lt;o:p&gt;  &lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td style="padding: 1.5pt; color: rgb(0, 0, 0);"&gt; &lt;p class="MsoNormal"&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;Weekday&lt;/span&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;&lt;o:p&gt;  &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt; &lt;td style="padding: 1.5pt; color: rgb(0, 0, 0);"&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:100%;"&gt;&lt;b&gt;&lt;span style="font-family:Verdana;"&gt;DW&lt;/span&gt;&lt;span style="font-family:Verdana;"&gt;&lt;o:p&gt;  &lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td style="padding: 1.5pt; color: rgb(0, 0, 0);"&gt; &lt;p class="MsoNormal"&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;Year&lt;/span&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;&lt;o:p&gt;  &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt; &lt;td style="padding: 1.5pt; color: rgb(0, 0, 0);"&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:100%;"&gt;&lt;b&gt;&lt;span style="font-family:Verdana;"&gt;YY,  YYYY&lt;/span&gt;&lt;span style="font-family:Verdana;"&gt;&lt;o:p&gt;  &lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2967271806809978211-4440276557232764793?l=oracledbs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracledbs.blogspot.com/feeds/4440276557232764793/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2967271806809978211&amp;postID=4440276557232764793' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/4440276557232764793'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/4440276557232764793'/><link rel='alternate' type='text/html' href='http://oracledbs.blogspot.com/2008/02/sql-server_07.html' title='SQL Server'/><author><name>Real Time Scenario</name><uri>http://www.blogger.com/profile/11930020132547308855</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2967271806809978211.post-2462552176463923137</id><published>2008-02-07T23:22:00.000-08:00</published><updated>2008-02-07T23:38:09.061-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Literals'/><title type='text'>SQL Server</title><content type='html'>&lt;p class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;b&gt;&lt;span style=";font-family:Verdana;" &gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;span style="color: rgb(153, 0, 0);font-size:130%;" &gt;&lt;b&gt;&lt;span style=";font-family:Verdana;" &gt;Using Literals&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;&lt;br /&gt;&lt;br /&gt;One can use Literals to  make output more readable. A literal is a string surrounded by single quotation  marks included in the column_list and displayed as another column in the query  result&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(153, 51, 0);"&gt;Examples:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;SELECT 'Employee Name:',fname +','+lname&lt;br /&gt;FROM  employee&lt;br /&gt;&lt;br /&gt;OR&lt;br /&gt;&lt;br /&gt;SELECT fname, lname, 'Employee ID is' , emp_id&lt;br /&gt;FROM  employee&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;&lt;b style="color: rgb(153, 51, 0);"&gt;Important Mathematical Functions&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Mathematical  functions enable one to return mathematical data using the syntax:&lt;o:p&gt;  &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;ul type="disc"&gt;&lt;li class="MsoNormal" style=""&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;Arithmetic operators can be used  with data types: int, smallint, tinyint, numeric, decimal, float, real, money  and smallmoney &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt; &lt;/li&gt;&lt;li class="MsoNormal" style=""&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;With arithmetic operators two  types of precedence exists: &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt; &lt;ul type="circle"&gt;&lt;li class="MsoNormal" style=""&gt;&lt;a href="http://oracledbs.blogspot.com/"&gt;&lt;span style="color: rgb(153, 51, 0); font-weight: bold;font-size:100%;" &gt;&lt;span style=";font-family:Verdana;" &gt;Datatype  Precedence&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;-  Arithmetic precedence exists when arithmetic operations are performed on  different data types. In case of usage of different data types, the smaller data  type is converted to higher data type. Like if we multiply smallint by an int,  the result will be an int, but in case of money result will always be of data  type money &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt; &lt;/li&gt;&lt;li class="MsoNormal" style=""&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;Operator precedence is used when  multiple operators are used. It uses same math concept of &lt;b&gt;BODMAS&lt;/b&gt;  &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;a href="http://oracledbs.blogspot.com/"&gt;&lt;span style="color: rgb(153, 0, 0);font-size:100%;" &gt;&lt;b&gt;&lt;span style=";font-family:Verdana;" &gt;Select  function_name(parameters)&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/a&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin-bottom: 12pt; margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin-bottom: 12pt; margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;1.&lt;span style="font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:'Times New Roman';" &gt;       &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;b&gt;&lt;span style=";font-family:Verdana;" &gt;Abs  (numeric_expr)&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;:  Provides absolute value&lt;br /&gt;&lt;br /&gt;Example. Select Abs (-123)-[123]&lt;o:p&gt;  &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin-bottom: 12pt; margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin-bottom: 12pt; margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;2.&lt;span style="font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:'Times New Roman';" &gt;       &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;b&gt;&lt;span style=";font-family:Verdana;" &gt;Ceiling (numeric_expr)  &lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;: Provides  smallest integer greater than or equal to specified value&lt;br /&gt;&lt;br /&gt;Example. Select  ceiling(123.3), ceiling(-123.3)-[124,-123]&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin-bottom: 12pt; margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin-bottom: 12pt; margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;3.&lt;span style="font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:'Times New Roman';" &gt;       &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;b&gt;&lt;span style=";font-family:Verdana;" &gt;Floor  (numeric_expr)&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt; :  Provides largest integer less than or equal to specified value&lt;br /&gt;&lt;br /&gt;Example.  Select floor (123.3), floor(-123.3.)-[123, -124]&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin-bottom: 12pt; margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin-bottom: 12pt; margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;4.&lt;span style="font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:'Times New Roman';" &gt;       &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;b&gt;&lt;span style=";font-family:Verdana;" &gt;Round (numeric_expr,  length)&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt; :  Provides numeric expression rounded to the specified length in an integer  value&lt;br /&gt;&lt;br /&gt;Example. Select Round (1234.56,1), Round ($123.67,1)-[1234.6,123.7]  &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin-bottom: 12pt; margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin-bottom: 12pt; margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;5.&lt;span style="font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:'Times New Roman';" &gt;       &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;b&gt;&lt;span style=";font-family:Verdana;" &gt;Square  (float_expr)&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt; :  Provides square value&lt;br /&gt;&lt;br /&gt;Example. Select square (9)-(81)&lt;o:p&gt;  &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin-bottom: 12pt; margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin-bottom: 12pt; margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;6.&lt;span style="font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:'Times New Roman';" &gt;       &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;b&gt;&lt;span style=";font-family:Verdana;" &gt;SQRT (float_expr)&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt; :&lt;br /&gt;&lt;br /&gt;Example. Select sqrt  (9)-[3]&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin-bottom: 12pt; margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin-bottom: 12pt; margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;7.&lt;span style="font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:'Times New Roman';" &gt;       &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;b&gt;&lt;span style=";font-family:Verdana;" &gt;POWER (numeric_expression,  y)&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt; : Provides  value of numeric expression to the power of y&lt;br /&gt;&lt;br /&gt;Example. Select  Power(2,3)-[8]&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;Remember when using mathematical  functions with &lt;a href="http://oracledbs.blogspot.com/"&gt;&lt;b style="color: rgb(153, 0, 0);"&gt;monetary data type&lt;/b&gt;&lt;/a&gt; always use it with a dollar sign  otherwise the value will be treated as numeric value&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;&lt;b&gt;Important String  Functions&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;String functions are used for manipulation of character  data type&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;span style=";font-family:Symbol;font-size:100%;"  &gt;·&lt;/span&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;&lt;span style=""&gt;   &lt;/span&gt;&lt;b&gt;+ (expression, expression)&lt;/b&gt; : Concatenates two or more  strings&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(153, 0, 0);"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;&lt;span style="font-weight: bold; color: rgb(153, 0, 0);"&gt;Example&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Select lname +','+ fname +'.' As Name from  employee&lt;br /&gt;&lt;br /&gt;OR&lt;br /&gt;&lt;br /&gt;SELECT ('abc' + 'def') -[abcdef]&lt;o:p&gt;  &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;span style=";font-family:Symbol;font-size:100%;"  &gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;span style=";font-family:Symbol;font-size:100%;"  &gt;·&lt;/span&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;&lt;span style=""&gt;   &lt;/span&gt;&lt;b&gt;ASCII (char_expr)&lt;/b&gt; :Provides ASCII code for left-most  character&lt;br /&gt;&lt;br /&gt;Example&lt;br /&gt;&lt;br /&gt;Select ASCII ('A')-[65]&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;span style=";font-family:Symbol;font-size:100%;"  &gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;span style=";font-family:Symbol;font-size:100%;"  &gt;·&lt;/span&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;&lt;span style=""&gt;   &lt;/span&gt;&lt;b&gt;Char (integer_expr)&lt;/b&gt; : Provides character equivalent of ASCII code  value&lt;br /&gt;&lt;br /&gt;Example: Select Char(97)-[a]&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;&lt;br /&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;div align="center"&gt; &lt;table style="background: rgb(223, 239, 255) none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; width: 50%;color:#dfefff;" bg border="0" cellpadding="0" width="50%"&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td style="padding: 1.5pt;"&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:100%;"&gt;&lt;b&gt;&lt;span style=";font-family:Verdana;" &gt;Control Character &lt;/span&gt;&lt;span style=";font-family:Verdana;" &gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt; &lt;td style="padding: 1.5pt;"&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:100%;"&gt;&lt;b&gt;&lt;span style=";font-family:Verdana;" &gt;Value  &lt;/span&gt;&lt;span style=";font-family:Verdana;" &gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td style="padding: 1.5pt;"&gt; &lt;p class="MsoNormal"&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;Tab&lt;/span&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;&lt;o:p&gt;  &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt; &lt;td style="padding: 1.5pt;"&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:100%;"&gt;&lt;b&gt;&lt;span style=";font-family:Verdana;" &gt;Char  (9)&lt;/span&gt;&lt;span style=";font-family:Verdana;" &gt;&lt;o:p&gt;  &lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td style="padding: 1.5pt;"&gt; &lt;p class="MsoNormal"&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;Linefeed  &lt;/span&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt; &lt;td style="padding: 1.5pt;"&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:100%;"&gt;&lt;b&gt;&lt;span style=";font-family:Verdana;" &gt;Char  (10)&lt;/span&gt;&lt;span style=";font-family:Verdana;" &gt;&lt;o:p&gt;  &lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td style="padding: 1.5pt;"&gt; &lt;p class="MsoNormal"&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;Carriage  return&lt;/span&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;&lt;o:p&gt;  &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt; &lt;td style="padding: 1.5pt;"&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:100%;"&gt;&lt;b&gt;&lt;span style=";font-family:Verdana;" &gt;Char(13)&lt;/span&gt;&lt;span style=";font-family:Verdana;" &gt;&lt;o:p&gt;  &lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt; &lt;p class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Example&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Use  Northwind&lt;br /&gt;GO&lt;br /&gt;SELECT FirstName + ' ' + LastName, + CHAR(13) + Address, +  CHAR(13)+ City, Region +char(10)&lt;br /&gt;FROM Employees&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;span style=";font-family:Symbol;font-size:100%;"  &gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;span style=";font-family:Symbol;font-size:100%;"  &gt;·&lt;/span&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;&lt;span style=""&gt;   &lt;/span&gt;PATINDEX('% pattern%', expression): Returns starting position of first  occurance in expression&lt;br /&gt;&lt;br /&gt;Example&lt;br /&gt;&lt;br /&gt;select  patindex('%bv%','ronvcbvvbc')&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;span style=";font-family:Symbol;font-size:100%;"  &gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;span style=";font-family:Symbol;font-size:100%;"  &gt;·&lt;/span&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;&lt;span style=""&gt;   &lt;/span&gt;&lt;b&gt;Lower (char_expr)&lt;/b&gt;: Converts to lower  case&lt;br /&gt;&lt;br /&gt;Example&lt;br /&gt;&lt;br /&gt;Select Lower ('ABCD')-[abcd]&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;span style=";font-family:Symbol;font-size:100%;"  &gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;span style=";font-family:Symbol;font-size:100%;"  &gt;·&lt;/span&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;&lt;span style=""&gt;   &lt;/span&gt;&lt;b&gt;Upper (char_expr)&lt;/b&gt;: Converts to upper  case&lt;br /&gt;&lt;br /&gt;Example&lt;br /&gt;&lt;br /&gt;Select Upper ('abcd')-[ABCD]&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;span style=";font-family:Symbol;font-size:100%;"  &gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;span style=";font-family:Symbol;font-size:100%;"  &gt;·&lt;/span&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;&lt;span style=""&gt;   &lt;/span&gt;&lt;b&gt;Left (char_expr, integer_expr)&lt;/b&gt; : Provides character string  starting from the left and preceeding integer_expr  character&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(153, 0, 0);"&gt;Example&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Select left('Seattle' ,2) -  [se]&lt;br /&gt;&lt;br /&gt;OR&lt;br /&gt;&lt;br /&gt;USE pubs&lt;br /&gt;GO&lt;br /&gt;SELECT LEFT (title, 5) as Titles&lt;br /&gt;FROM  titles&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;span style=";font-family:Symbol;font-size:100%;"  &gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;span style=";font-family:Symbol;font-size:100%;"  &gt;·&lt;/span&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;&lt;span style=""&gt;   &lt;/span&gt;&lt;b&gt;Right (char_expr, integer_expr)&lt;/b&gt; : Provides character string  starting from the integer_expr character from Right&lt;br /&gt;&lt;br /&gt;Example&lt;br /&gt;&lt;br /&gt;Select  Right ('Seattle' ,2) --[le]&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;span style=";font-family:Symbol;font-size:100%;"  &gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;span style=";font-family:Symbol;font-size:100%;"  &gt;·&lt;/span&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;&lt;span style=""&gt;   &lt;/span&gt;&lt;b&gt;LTRIM (char_expr)&lt;/b&gt; : Returns data without leading blanks  Example&lt;br /&gt;&lt;br /&gt;Select Ltrim (' Computers')-[Computers]&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;span style=";font-family:Symbol;font-size:100%;"  &gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;span style=";font-family:Symbol;font-size:100%;"  &gt;·&lt;/span&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;&lt;span style=""&gt;   &lt;/span&gt;&lt;b&gt;RTRIM (char_expr)&lt;/b&gt; : Returns data without trailing  blanks&lt;br /&gt;&lt;br /&gt;Example&lt;br /&gt;&lt;br /&gt;Select Ltrim ('Computers ')-[Computers]&lt;o:p&gt;  &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;span style=";font-family:Symbol;font-size:100%;"  &gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;span style=";font-family:Symbol;font-size:100%;"  &gt;·&lt;/span&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;&lt;span style=""&gt;   &lt;/span&gt;&lt;b&gt;REPLACE ('string_expression1', 'string_expression2',  'string_expression3')&lt;/b&gt; :Replaces all occurrences of srting2 in string1 with  string3&lt;br /&gt;&lt;br /&gt;Example. Select Replace ('abcde', 'bc','oo') -[aoode]&lt;o:p&gt;  &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;span style=";font-family:Symbol;font-size:100%;"  &gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;span style=";font-family:Symbol;font-size:100%;"  &gt;·&lt;/span&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;&lt;span style=""&gt;   &lt;/span&gt;&lt;b&gt;Reverse (char_expr) &lt;/b&gt;: Returns reverse of character  expression&lt;br /&gt;&lt;br /&gt;Example&lt;br /&gt;&lt;br /&gt;Select Reverse('ABCD')-[DCBA]&lt;o:p&gt;  &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;span style=";font-family:Symbol;font-size:100%;"  &gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;span style=";font-family:Symbol;font-size:100%;"  &gt;·&lt;/span&gt;&lt;span style=";font-family:Verdana;font-size:7;"  &gt;&lt;span style=";font-size:100%;" &gt;   &lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;b&gt;SUBSTRING(expression, start, length)&lt;/b&gt;: Returns part of character  string&lt;br /&gt;&lt;br /&gt;Example&lt;br /&gt;&lt;br /&gt;SELECT SUBSTRING('abcdef', 2, 3) as  X&lt;br /&gt;&lt;br /&gt;X&lt;br /&gt;----&lt;br /&gt;bcd&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;span style=";font-family:Verdana;font-size:7;"  &gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2967271806809978211-2462552176463923137?l=oracledbs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracledbs.blogspot.com/feeds/2462552176463923137/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2967271806809978211&amp;postID=2462552176463923137' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/2462552176463923137'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/2462552176463923137'/><link rel='alternate' type='text/html' href='http://oracledbs.blogspot.com/2008/02/using-literals-one-can-use-literals-to.html' title='SQL Server'/><author><name>Real Time Scenario</name><uri>http://www.blogger.com/profile/11930020132547308855</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2967271806809978211.post-7985630132590651145</id><published>2008-02-07T22:40:00.000-08:00</published><updated>2008-02-07T23:21:34.314-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SELECT clause'/><title type='text'>SQL Server</title><content type='html'>&lt;p class="MsoNormal"&gt;&lt;span style="font-size:100%;"&gt;&lt;b&gt;&lt;span style=";font-family:Verdana;" &gt;T-SQL&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;&lt;br /&gt;&lt;br /&gt;Now we will see how to  write simple SQL queries. For understanding T-SQL and to use examples below use  Query Analyzer in SQL Server&lt;br /&gt;&lt;br /&gt;&lt;b&gt;The Select Statement&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;One can  use a SQL query to retrieve the data one wants from the database.&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;&lt;br /&gt;A query has  three parts: &lt;b&gt;SELECT&lt;/b&gt;,&lt;b&gt; FROM&lt;/b&gt;,    and &lt;b&gt;WHERE&lt;/b&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;ul type="disc"&gt;&lt;li class="MsoNormal" style=""&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;SELECT tells SQL Server which  columns one want to see as the result of the query &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt; &lt;/li&gt;&lt;li class="MsoNormal" style=""&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;FROM specifies which table or  tables you want to use in the query. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt; &lt;/li&gt;&lt;li class="MsoNormal" style=""&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;WHERE limits which rows one want  to see &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt; &lt;/li&gt;&lt;li class="MsoNormal" style=""&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;The syntax isn't case sensitive,  but generally people use uppercase and lowercase to distinguish the commands  from the object names &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;&lt;span style="font-weight: bold; font-style: italic;"&gt;A typical query looks like  this:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;SELECT col1, col2, col3......&lt;br /&gt;FROM table1&lt;br /&gt;WHERE col1 = search  condition&lt;br /&gt;&lt;br /&gt;Consider this simple query:&lt;br /&gt;&lt;br /&gt;USE pubs&lt;br /&gt;GO&lt;br /&gt;SELECT *  FROM authors&lt;br /&gt;GO&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;ul type="disc"&gt;&lt;li class="MsoNormal" style=""&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;The phrase "USE pubs" ensures  that statement queries the pubs database. One could instead select the database  in the DB window on the Toolbar &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt; &lt;/li&gt;&lt;li class="MsoNormal" style=""&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;GO ensures that SQL Server has  completed the previous command before the next one starts &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt; &lt;/li&gt;&lt;li class="MsoNormal" style=""&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;This query will return all  columns and rows in the authors table. Inside SQL Server * is turned into name  of columns of the table &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;But one of the three elements-the  WHERE clause-is missing from this statement. So if one uses this statement, SQL  Server will return all the rows. A query without a WHERE clause can return a  large amount of data, increasing network traffic&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color:red;"&gt;Warning&lt;/span&gt;&lt;/b&gt;: An update or delete statement without a  WHERE clause to restrict the affected rows could be disastrous&lt;br /&gt;&lt;br /&gt;Because  the authors table in the pubs sample database is small, one can run this query  without worry. Click on the green arrow or press CTRL-E. Image 1 shows the  results. One needs to scroll the window to see all the columns and all the  rows&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Selecting Columns&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;If one wants to see only &lt;a href="http://oracledbs.blogspot.com/"&gt;&lt;span style="font-weight: bold;"&gt;certain&lt;/span&gt;&lt;/a&gt;  columns, one can restrict the output by listing the names of the columns one  want. One can run a system-stored procedure to determine the column names. From  the Query window, type and run:&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;&lt;b&gt;sp_help authors&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;One can  type this query in the same window as the previous query, and then highlight it  to run the line on its own. Or one can use the cursor or mouse to highlight the  word authors, and then press ALT-X. This action runs the sp_help stored  procedure on the highlighted table name. Both methods will yield the same  output-a list of columns and their data types and length&lt;br /&gt;&lt;br /&gt;&lt;a href="http://oracledbs.blogspot.com/"&gt;&lt;span style="font-weight: bold; color: rgb(102, 0, 0);"&gt;Another way one  can identify the column names is to add a line to the query:&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;SELECT *  FROM authors&lt;br /&gt;WHERE 0 = 1&lt;br /&gt;&lt;br /&gt;Because the WHERE condition is never met for  this query (zero can't equal one), the query won't produce output, as shown in  Image 2. But the query will return a page header that includes column names,  with the order and spacing in which they'll appear on the final query. Now one  can choose which columns you want to see by listing them in the&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;&lt;b&gt;SELECT clause&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;SELECT au_id, au_lname, au_fname, phone&lt;br /&gt;FROM  authors&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Note&lt;/b&gt; that commas separate the column names. For clarity,  FROM is now on the line below SELECT. If one runs this query, one'll see that  the output consists of only the four requested columns&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;&lt;b&gt;Changing the  Output Column Order&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;When one execute a query with select * from, the  column order will be same as the column order specified in the CREATE TABLE  statement but when one selects the columns from the column_list order does not  need to be same as the table column order. One can rearrange the column order in  the query output by rearranging the columns in the column  list&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;&lt;b&gt;Changing Column Header&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;The top row of the output lists  the names of the columns one selected. Programmers devised the column names, so  the names might not mean much to the person who sees the output report. One can  use T-SQL or ANSI standard syntax to rename the output columns. If one uses the  T-SQL syntax, supply the label first, followed by an equal sign, then the column  name:&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;The three ways in which we can change column headings are:&lt;o:p&gt;  &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;ul type="disc"&gt;&lt;li class="MsoNormal" style=""&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;Select column_heading=column_name  FROM Table_name&lt;br /&gt;&lt;br /&gt;Example&lt;br /&gt;SELECT EmployeeId=emp_id, lastname=lname FROM  employee &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt; &lt;/li&gt;&lt;li class="MsoNormal" style=""&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;SELECT column_name as column  heading From table_name&lt;br /&gt;&lt;br /&gt;Example&lt;br /&gt;SELECT emp_id as Employeeid , lname as  LastName, fname as Firstname FROM employee &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt; &lt;/li&gt;&lt;li class="MsoNormal" style=""&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;SELECT column_name column heading  From table_name&lt;br /&gt;&lt;br /&gt;Example&lt;br /&gt;SELECT emp_id 'Employee Id' , lname LastName,  fname Firstname FROM employee &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;&lt;br /&gt;One can use &lt;b&gt;square  brackets ([])&lt;/b&gt; or &lt;b&gt;single quotation marks&lt;/b&gt; to encapsulate column headings.,&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;span style=";font-family:Verdana;font-size:100%;"  &gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2967271806809978211-7985630132590651145?l=oracledbs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracledbs.blogspot.com/feeds/7985630132590651145/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2967271806809978211&amp;postID=7985630132590651145' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/7985630132590651145'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/7985630132590651145'/><link rel='alternate' type='text/html' href='http://oracledbs.blogspot.com/2008/02/sql-server.html' title='SQL Server'/><author><name>Real Time Scenario</name><uri>http://www.blogger.com/profile/11930020132547308855</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2967271806809978211.post-6169545896601066860</id><published>2008-01-22T23:01:00.000-08:00</published><updated>2008-02-07T14:58:30.581-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='HAVING AND ORDER BY clauses together'/><category scheme='http://www.blogger.com/atom/ns#' term='Using  WHERE'/><category scheme='http://www.blogger.com/atom/ns#' term='GROUP BY'/><title type='text'>How to Use  WHERE , GROUP BY , HAVING AND ORDER BY clauses together?</title><content type='html'>&lt;div style="TEXT-ALIGN: center"&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="FONT-WEIGHT: bold"&gt;&lt;br /&gt;&lt;br /&gt;&gt;&gt;&gt;Privious&gt;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt; &lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt;&lt;/strong&gt; &lt;/p&gt;&lt;p&gt;&lt;strong style="COLOR: rgb(102,0,0)"&gt;&lt;u&gt;GROUP BY CLAUSE :&lt;/u&gt; &lt;/strong&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Using a group function one can group entire table data and provide a single result,however&lt;br /&gt;you can use the GROUP BY clause to break the result set into logical groupings and get a result for each group. &lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#990000;"&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/span&gt; &lt;/p&gt;&lt;p&gt;&lt;span style="color:#990000;"&gt;&lt;strong&gt;Q. &lt;/strong&gt;To display no of employees in each dept we can use.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;SQL &gt;SELECT DEPTNO,COUNT(*) FROM EMP GROUP BY DEPTNO;&lt;/p&gt;&lt;p&gt;DEPTNO COUNT(*)&lt;br /&gt;---------- ----------&lt;br /&gt;10 3&lt;br /&gt;20 5&lt;br /&gt;30 6&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#990000;"&gt;&lt;strong&gt;Q. &lt;/strong&gt;The total salary paid for each &lt;a href="http://oracledbs.blogspot.com/"&gt;department&lt;/a&gt; and also when the last recruitment was made in that department.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;SQL &gt;SELECT DEPTNO,MAX(HIREDATE),SUM(SAL) FROM EMP GROUP BY DEPTNO;&lt;/p&gt;&lt;p&gt;DEPTNO MAX(HIRED SUM(SAL)&lt;br /&gt;---------- --------- ----------&lt;br /&gt;10 23-JAN-82 8750&lt;br /&gt;20 23-MAY-87 10875&lt;br /&gt;30 03-DEC-81 9400&lt;/p&gt;&lt;p&gt;When grouping using the GROUP BY clause you cannot use a WHERE clause to restrict the groups that are returned, SQL provides another selection keyword, HAVING, to replace the WHERE clause.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#990000;"&gt;&lt;strong&gt;Q,&lt;/strong&gt;To diplay those departments which have more than 5 employees in them we can write.&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt; &lt;/p&gt;&lt;p&gt;SQL &gt;SELECT DEPTNO, COUNT(*) FROM EMP&lt;br /&gt;GROUP BY DEPTNO&lt;br /&gt;HAVING COUNT(*) &gt; 5 ;&lt;/p&gt;&lt;p&gt;DEPTNO COUNT(*)&lt;br /&gt;---------- ----------&lt;br /&gt;30 6&lt;/p&gt;&lt;div style="TEXT-ALIGN: center"&gt;&lt;span style="FONT-STYLE: italic;font-size:130%;" &gt;&lt;span style="FONT-WEIGHT: bold"&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;p style="COLOR: rgb(153,0,0)"&gt;&lt;strong&gt;&lt;em&gt;&lt;u&gt;Using WHERE , GROUP BY , HAVING AND ORDER BY clauses together.&lt;/u&gt;&lt;/em&gt;&lt;/strong&gt; &lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="color:#993300;"&gt;General form of the SELECT statement is&lt;/span&gt;&lt;/strong&gt; &lt;/p&gt;&lt;p align="center"&gt;&lt;strong&gt;&lt;/strong&gt; &lt;/p&gt;&lt;p align="center"&gt;&lt;strong&gt;SELECT &lt;/strong&gt;&lt;/p&gt;&lt;p align="center"&gt;&lt;strong&gt;&lt;column1,&gt;FROM &lt;/strong&gt;&lt;/p&gt;&lt;p align="center"&gt;&lt;strong&gt;&lt;table1,&gt;&lt;/strong&gt;&lt;strong&gt;WHERE&lt;/strong&gt;&lt;/p&gt;&lt;p align="center"&gt;&lt;strong&gt;&lt;where&gt;&lt;/strong&gt;&lt;strong&gt;GROUP BY &lt;/strong&gt;&lt;/p&gt;&lt;p align="center"&gt;&lt;strong&gt;HAVING &lt;/strong&gt;&lt;/p&gt;&lt;p align="center"&gt;&lt;strong&gt;&lt;having&gt;ORDER BY &lt;column1,&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;when all the above said clauses are used in a select query they need to appear in the order specified above, violation of which will lead to &lt;strong&gt;&lt;a href="http://oracledbs.blogspot.com/"&gt;Errors&lt;/a&gt;&lt;/strong&gt;.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;span style="color:#990000;"&gt;&lt;strong&gt;Q.&lt;/strong&gt; A query to display departments paid 500 or more and have 2 or less employess can be displayed as shown below&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;SQL &gt;SELECT DEPTNO ,COUNT(*) , SUM(SAL) FROM EMP&lt;br /&gt;2 WHERE JOB = 'CLERK'&lt;br /&gt;3 GROUP BY DEPTNO&lt;br /&gt;4 HAVING SUM(SAL) &gt;=500 AND COUNT(*) &lt;&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;DEPTNO COUNT(*) SUM(SAL)&lt;br /&gt;---------- ---------- ----------&lt;br /&gt;30 1 950&lt;br /&gt;10 1 1300&lt;/p&gt;&lt;br /&gt;&lt;p style="TEXT-ALIGN: center"&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="FONT-WEIGHT: bold"&gt;&gt;&gt;&gt;Next&gt;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2967271806809978211-6169545896601066860?l=oracledbs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracledbs.blogspot.com/feeds/6169545896601066860/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2967271806809978211&amp;postID=6169545896601066860' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/6169545896601066860'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/6169545896601066860'/><link rel='alternate' type='text/html' href='http://oracledbs.blogspot.com/2008/01/how-to-use-where-group-by-having-and.html' title='How to Use  WHERE , GROUP BY , HAVING AND ORDER BY clauses together?'/><author><name>Real Time Scenario</name><uri>http://www.blogger.com/profile/11930020132547308855</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2967271806809978211.post-7220907389335133903</id><published>2008-01-22T22:58:00.001-08:00</published><updated>2008-01-22T23:01:25.653-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Practice AGGREGATE FUNCTIONS'/><title type='text'>What are  AGGREGATE FUNCTIONS?</title><content type='html'>&lt;div style="text-align: center;"&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;br /&gt;&gt;&gt;&gt;Previous&gt;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;&lt;u&gt;FUNCTIONS : &lt;/u&gt;&lt;/strong&gt;These functions operate over a set of  values.They are also known as aggregate functions&lt;/p&gt; &lt;p&gt;&lt;strong&gt;  &lt;br /&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;MAX():&lt;/strong&gt; A function used find maximum value among the given  values.&lt;br /&gt;   &lt;br /&gt;   SQL &gt; SELECT MAX(SAL) FROM EMP;&lt;/p&gt; &lt;p&gt;   MAX(SAL)&lt;br /&gt; ---------&lt;br /&gt;    5000&lt;/p&gt; &lt;p&gt;&lt;strong&gt; &lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;MIN():&lt;/strong&gt; It returns minimun of the values in a column. &lt;br /&gt;&lt;br /&gt; SQL &gt; SELECT MIN(HIREDATE) FROM EMP;&lt;/p&gt; &lt;p&gt; MIN(HIRED&lt;br /&gt; ---------&lt;br /&gt; 17-DEC-80&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-weight: bold;"&gt;AVG():&lt;/span&gt; Gives the average of  values  in a column.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;SQL &gt;SELECT  AVG(SAL) FROM EMP;&lt;/p&gt; &lt;p&gt;  AVG(SAL)&lt;br /&gt;----------&lt;br /&gt;2073.21429&lt;/p&gt; &lt;p&gt;&lt;strong&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;SUM():&lt;/strong&gt; Sum of the values in a column&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;SQL &gt;SELECT  SUM(SAL) FROM EMP;&lt;/p&gt; &lt;p&gt;  SUM(SAL)&lt;br /&gt;----------&lt;br /&gt;     29025&lt;/p&gt; &lt;p&gt;&lt;strong&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;COUNT(*):&lt;/strong&gt; Gives number of columns in a table.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;SQL  &gt;SELECT COUNT(*) FROM DUAL;&lt;/p&gt; &lt;p&gt;  COUNT(*)&lt;br /&gt;----------&lt;br /&gt;         1&lt;/p&gt; &lt;p&gt;SQL &gt;SELECT COUNT(*) FROM EMP;&lt;/p&gt; &lt;p&gt;  COUNT(*)&lt;br /&gt;----------&lt;br /&gt;        14&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;COUNT(&lt;columnname&gt;):&lt;/strong&gt; Gives no of not null ENTRIE  (VALUES) in that column.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;SQL &gt;SELECT COUNT(COMM) FROM EMP;&lt;/p&gt; &lt;p&gt;COUNT(COMM)&lt;br /&gt;-----------&lt;br /&gt;          4&lt;/p&gt; &lt;p&gt;&lt;br /&gt;SQL &gt;SELECT COUNT(DISTINCT JOB) FROM EMP;&lt;/p&gt; &lt;p&gt;COUNT(DISTINCTJOB)&lt;br /&gt;------------------&lt;br /&gt;                  5&lt;/p&gt;&lt;p&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-weight: bold;"&gt;Explanation:&lt;/span&gt; Using&lt;strong&gt; DISTICT,  &lt;/strong&gt;duplicate values can be  suppressed.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;&gt;&gt;&gt;Next&gt;&gt;&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2967271806809978211-7220907389335133903?l=oracledbs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracledbs.blogspot.com/feeds/7220907389335133903/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2967271806809978211&amp;postID=7220907389335133903' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/7220907389335133903'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/7220907389335133903'/><link rel='alternate' type='text/html' href='http://oracledbs.blogspot.com/2008/01/what-are-aggregate-functions.html' title='What are  AGGREGATE FUNCTIONS?'/><author><name>Real Time Scenario</name><uri>http://www.blogger.com/profile/11930020132547308855</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2967271806809978211.post-4668436970530498799</id><published>2008-01-22T22:55:00.000-08:00</published><updated>2008-01-22T22:57:55.696-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Practice CONVERSION FUNCTIONS'/><title type='text'>What are CONVERSION FUNCTIONS?</title><content type='html'>&lt;div style="text-align: center;"&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;&gt;&gt;&gt;Previous&gt;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;&lt;u&gt;CONVERSION FUNCTIONS: &lt;/u&gt;&lt;/strong&gt;&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt;&lt;strong&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;TO_CHAR:&lt;/strong&gt; This function is used to convert a date or number  to character string.&lt;br /&gt;SQL&gt;  SELECT TO_CHAR(SYSDATE,'DAY DD MONTH YYYY')  FROM DUAL&lt;/p&gt; &lt;p&gt;TO_CHAR (SYSDATE,'DAYDDMONTH&lt;br /&gt;---------------------------&lt;br /&gt;SATURDAY 01  JANUARY   2005&lt;/p&gt; &lt;p&gt;SQL&gt; SELECT TO_CHAR (SYSDATE,' DD DY MM YY') FROM DUAL;&lt;/p&gt; &lt;p&gt;TO_CHAR (SYSDA&lt;br /&gt;-------------&lt;br /&gt; 01 SAT 01 05&lt;/p&gt; &lt;p&gt;&lt;strong&gt;NVL()  Function:&lt;/strong&gt; This function is used to substitute any  null value with a user-defined value.&lt;/p&gt; &lt;p&gt;Consider the following data from EMP table of SCOTT. &lt;/p&gt; &lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;SQL&gt; SELECT EMPNO, ENAME, SAL, COMM FROM EMP;&lt;/p&gt; &lt;p&gt;     EMPNO  ENAME             SAL       COMM&lt;br /&gt;---------- ----------  ---------- -------------------------&lt;br /&gt;      7369  SMITH                800&lt;br /&gt;      7499  ALLEN            1600            300&lt;br /&gt;      7521   WARD             1250            500&lt;br /&gt;      7566   JONES            2975&lt;br /&gt;      7654  MARTIN          1250           1400&lt;br /&gt;      7698  BLAKE           2850&lt;br /&gt;      7782   CLARK           2450&lt;br /&gt;      7788  SCOTT            3000&lt;br /&gt;      7839   KING                5000&lt;br /&gt;      7844  TURNER          1500                  0&lt;br /&gt;      7876  ADAMS           1100&lt;br /&gt;      7900  JAMES              950&lt;br /&gt;      7902  FORD              3000&lt;br /&gt;      7934  MILLER             1300&lt;/p&gt; &lt;p&gt;&lt;br /&gt;In the above table except for 7499, 7521, 7654 and 7844 all others  commissions are null&lt;br /&gt;To display their commission as “0” (zero)&lt;br /&gt;We can use  &lt;strong&gt;NVL() &lt;/strong&gt;function as shown below.&lt;/p&gt; &lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;SQL&gt; SELECT EMPNO, ENAME, SAL, NVL (COMM, 100) FROM EMP&lt;/p&gt; &lt;p&gt;     EMPNO  ENAME             SAL   NVL(COMM,100)&lt;br /&gt;      ----------  ---------- ---------- -------------&lt;br /&gt;      7369  SMITH             800          100&lt;br /&gt;      7499  ALLEN            1600         300&lt;br /&gt;      7521   WARD             1250         500&lt;br /&gt;      7566  JONES            2975          100&lt;br /&gt;      7654  MARTIN           1250        1400&lt;br /&gt;      7698   BLAKE            2850         100&lt;br /&gt;      7782  CLARK            2450          100&lt;br /&gt;      7788  SCOTT            3000         100&lt;br /&gt;      7839   KING             5000         100&lt;br /&gt;      7844  TURNER           1500          0&lt;br /&gt;      7876  ADAMS            1100         100&lt;br /&gt;      7900   JAMES             950         100&lt;br /&gt;      7902  FORD             3000          100&lt;br /&gt;      7934  MILLER           1300         100&lt;/p&gt; &lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;SQL&gt; SELECT EMPNO, ENAME, SAL, NVL (COMM, 888) FROM EMP&lt;/p&gt; &lt;p&gt;     EMPNO  ENAME         SAL  NVL(COMM,888)&lt;br /&gt;---------- ----------  ---------- -------------&lt;br /&gt;      7369  SMITH          800            888&lt;br /&gt;      7499  ALLEN         1600           300&lt;br /&gt;      7521  WARD           1250           500&lt;br /&gt;      7566  JONES         2975           888&lt;br /&gt;      7654   MARTIN        1250          1400&lt;br /&gt;      7698  BLAKE         2850            888&lt;br /&gt;      7782  CLARK         2450           888&lt;br /&gt;      7788  SCOTT          3000           888&lt;br /&gt;      7839  KING          5000           888&lt;br /&gt;      7844   TURNER        1500             0&lt;br /&gt;      7876 ADAMS         1100            888&lt;br /&gt;      7900  JAMES          950           888&lt;br /&gt;      7902  FORD           3000           888&lt;br /&gt;      7934  MILLER        1300           888&lt;/p&gt; &lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;In above queries we have seen how to substitute a value when the comm is  null.&lt;br /&gt;If one want to display "Commission not payed" against the employees  who have no&lt;br /&gt;commission we can write the following query.&lt;/p&gt; &lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;SQL &gt; SELECT ENAME, SAL, NVL(TO_CHAR(COMM),'Commission Not Payed') FROM  EMP&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;ENAME             SAL  NVL(TO_CHAR(COMM),'COMMISSIONNOTPAYED')&lt;br /&gt;----------  ---------- ----------------------------------------&lt;br /&gt;SMITH             800   Commission Not Payed&lt;br /&gt;ALLEN            1600  300&lt;br /&gt;WARD             1250   500&lt;br /&gt;JONES            2975  Commission Not Payed&lt;br /&gt;MARTIN           1250   1400&lt;br /&gt;BLAKE            2850  Commission Not Payed&lt;br /&gt;CLARK            2450   Commission Not Payed&lt;br /&gt;SCOTT            3000  Commission Not  Payed&lt;br /&gt;KING             5000  Commission Not Payed&lt;br /&gt;TURNER           1500   0&lt;br /&gt;ADAMS            1100  Commission Not Payed&lt;br /&gt;JAMES             950   Commission Not Payed&lt;br /&gt;FORD             3000  Commission Not  Payed&lt;br /&gt;MILLER           1300  Commission Not Payed&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style="text-align: center;"&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;&gt;&gt;&gt;Next&gt;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="text-align: center;"&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="text-align: center;"&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;/p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2967271806809978211-4668436970530498799?l=oracledbs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracledbs.blogspot.com/feeds/4668436970530498799/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2967271806809978211&amp;postID=4668436970530498799' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/4668436970530498799'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/4668436970530498799'/><link rel='alternate' type='text/html' href='http://oracledbs.blogspot.com/2008/01/what-are-conversion-functions.html' title='What are CONVERSION FUNCTIONS?'/><author><name>Real Time Scenario</name><uri>http://www.blogger.com/profile/11930020132547308855</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2967271806809978211.post-2861755453115572649</id><published>2008-01-22T22:54:00.000-08:00</published><updated>2008-01-22T22:55:21.809-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SYSDATE Functions'/><category scheme='http://www.blogger.com/atom/ns#' term='Practice USER'/><title type='text'>What are USER, SYSDATE Functions?</title><content type='html'>&lt;p&gt;The &lt;strong&gt;USER, SYSDATE&lt;/strong&gt; Functions:&lt;br /&gt; &lt;br /&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;USER  &lt;/strong&gt; function displays login name of the user.&lt;/p&gt;  &lt;p&gt;SQL&gt; SELECT USER FROM DUAL;&lt;/p&gt;  &lt;p&gt;USER&lt;br /&gt;------------------------------&lt;br /&gt;SCOTT&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;SYSDATE&lt;/strong&gt;  function displays system date.(Date in your  windows)&lt;/p&gt;  &lt;p&gt;SQL&gt; SELECT SYSDATE FROM DUAL;&lt;/p&gt;  &lt;p&gt;SYSDATE&lt;br /&gt;---------&lt;br /&gt;1-JAN-05&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt; &lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2967271806809978211-2861755453115572649?l=oracledbs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracledbs.blogspot.com/feeds/2861755453115572649/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2967271806809978211&amp;postID=2861755453115572649' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/2861755453115572649'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/2861755453115572649'/><link rel='alternate' type='text/html' href='http://oracledbs.blogspot.com/2008/01/what-are-user-sysdate-functions.html' title='What are USER, SYSDATE Functions?'/><author><name>Real Time Scenario</name><uri>http://www.blogger.com/profile/11930020132547308855</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2967271806809978211.post-440838936958508985</id><published>2008-01-22T22:51:00.000-08:00</published><updated>2008-01-22T22:54:22.352-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Practice DATE FUNCTIONS'/><title type='text'>Practice DATE FUNCTIONS</title><content type='html'>&lt;div style="text-align: center;"&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;br /&gt;&gt;&gt;&gt;Previous&gt;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;&lt;u&gt;DATE FUNCTIONS:&lt;br /&gt;&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;/strong&gt;          &lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-weight: bold;"&gt; ADD_MONTHS(date,  n) : &lt;/span&gt;Adds n months to the specified date .&lt;/p&gt; &lt;p&gt;  SQL&gt; SELECT  ADD_MONTHS('1-JAN-05',5) FROM DUAL;&lt;/p&gt; &lt;p&gt;  ADD_MONTHS&lt;br /&gt;  ------------------&lt;br /&gt;  01-JUN-05&lt;/p&gt; &lt;p&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-weight: bold;"&gt;LAST_DAY(date):&lt;/span&gt; Gives last date of the specified month (date).&lt;/p&gt; &lt;p&gt;SQL&gt; SELECT LAST_DAY('1-JAN-05') FROM DUAL;&lt;/p&gt; &lt;p&gt;LAST_DAY(&lt;br /&gt;---------&lt;br /&gt;31-JAN-05&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;MONTHS_BETWEEN(date1, date2)&lt;/strong&gt;: It gives difference between  the two dates date1, date2 in months.&lt;/p&gt; &lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;SQL&gt;  SELECT MONTHS_BETWEEN('31-DEC-05','1-JAN-05') FROM DUAL&lt;/p&gt; &lt;p&gt;MONTHS_BETWEEN('31-DEC-05','1-JAN-05')&lt;br /&gt;--------------------------------------&lt;br /&gt;                             11.9677419&lt;/p&gt; &lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;SQL&gt;  SELECT MONTHS_BETWEEN('31-JUL-05','1-JUL-05') FROM DUAL&lt;/p&gt; &lt;p&gt;MONTHS_BETWEEN('31-JUL-05','1-JUL-05')&lt;br /&gt;--------------------------------------&lt;br /&gt;                             .967741935&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;NEXT_DAY(date, ‘day’ ) &lt;/strong&gt;:  It gives date of the next  occurrence of the specified day after the given date.&lt;br /&gt; &lt;/p&gt; &lt;p&gt;SQL&gt; SELECT NEXT_DAY('01-JAN-05','FRI') FROM DUAL;&lt;/p&gt; &lt;p&gt;NEXT_DAY(                                 (Next Friday after 1-jan-05 is on  7-jan-05)&lt;br /&gt;---------&lt;br /&gt;07-JAN-05 &lt;/p&gt; &lt;p&gt;&lt;strong&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;TO_DATE (string)&lt;/strong&gt;: This function converts a string into an  Oracle date.&lt;/p&gt; &lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;SQL&gt; SELECT TO_DATE('01 JANUARY 2005','DD MONTH YYYY') FROM DUAL;&lt;/p&gt; &lt;p&gt;TO_DATE('&lt;br /&gt;---------&lt;br /&gt;01-JAN-05&lt;/p&gt; &lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;SQL&gt; SELECT TO_DATE('MAR 05 01','MON YY DD') FROM DUAL;&lt;/p&gt; &lt;p&gt;TO_DATE('&lt;br /&gt;---------&lt;br /&gt;01-MAR-05&lt;/p&gt; &lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;SQL&gt; SELECT TO_DATE('01/01/05', 'DD/MM/YY') FROM DUAL;&lt;/p&gt; &lt;p&gt;TO_DATE('&lt;br /&gt;---------&lt;br /&gt;01-JAN-05&lt;/p&gt; &lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style="text-align: center;"&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;&gt;&gt;&gt;Next&gt;&gt;&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2967271806809978211-440838936958508985?l=oracledbs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracledbs.blogspot.com/feeds/440838936958508985/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2967271806809978211&amp;postID=440838936958508985' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/440838936958508985'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/440838936958508985'/><link rel='alternate' type='text/html' href='http://oracledbs.blogspot.com/2008/01/practice-date-functions.html' title='Practice DATE FUNCTIONS'/><author><name>Real Time Scenario</name><uri>http://www.blogger.com/profile/11930020132547308855</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2967271806809978211.post-9037822047110737595</id><published>2008-01-22T22:48:00.000-08:00</published><updated>2008-01-22T22:50:56.055-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Practice OTHER FUNCTIONS'/><title type='text'>Practice OTHER FUNCTIONS</title><content type='html'>&lt;div style="text-align: center;"&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;br /&gt;&gt;&gt;&gt;Previous&gt;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;p style="font-style: italic;"&gt;&lt;span style="font-size:130%;"&gt;&lt;strong&gt;&lt;u&gt;OTHER FUNCTIONS:&lt;/u&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;u&gt;&lt;br /&gt;&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;Note: Arguments to the below given functions are in terms of radians&lt;/p&gt; &lt;p&gt;&lt;strong&gt;COS(x): &lt;/strong&gt;It returns the Cosine of x.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;SQL&gt; SELECT COS(0)  FROM DUAL;&lt;br /&gt;    COS(0)&lt;br /&gt;----------&lt;br /&gt;         1&lt;br /&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;COSH(x)  &lt;/strong&gt;: It returns hyperbolic cosine of x.&lt;/p&gt; &lt;p&gt;SQL&gt; SELECT COSH(0) FROM DUAL;&lt;/p&gt; &lt;p&gt;   COSH(0)&lt;br /&gt;----------&lt;br /&gt;         1&lt;/p&gt; &lt;p&gt;&lt;strong&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;SIN(x) &lt;/strong&gt;: It returns sine of x.&lt;/p&gt; &lt;p&gt;SQL&gt; SELECT SIN(0) FROM DUAL;&lt;/p&gt; &lt;p&gt;    SIN(0)&lt;br /&gt;----------&lt;br /&gt;         0&lt;/p&gt; &lt;p&gt;&lt;strong&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;SINH(x&lt;/strong&gt;): It returns hyperbolic sine of x.&lt;/p&gt; &lt;p&gt;SQL&gt; SELECT SINH(0) FROM DUAL;&lt;/p&gt; &lt;p&gt;   SINH(0)&lt;br /&gt;----------&lt;br /&gt;         0&lt;/p&gt; &lt;p&gt;&lt;strong&gt;TAN(x)&lt;/strong&gt;: It returns tangent of x.&lt;/p&gt; &lt;p&gt;SQL&gt; SELECT TAN(0) FROM DUAL;&lt;/p&gt; &lt;p&gt;    TAN(0)&lt;br /&gt;----------&lt;br /&gt;         0&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt;&lt;strong&gt;TANH(x&lt;/strong&gt;): It returns hyperbolic tangent of x.&lt;br /&gt;SQL&gt;  SELECT TANH(0) FROM DUAL;&lt;/p&gt; &lt;p&gt;   TANH(0)&lt;br /&gt;----------&lt;br /&gt;         0&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style="text-align: center;"&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;&gt;&gt;&gt;Next&gt;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="text-align: center;"&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="text-align: center;"&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2967271806809978211-9037822047110737595?l=oracledbs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracledbs.blogspot.com/feeds/9037822047110737595/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2967271806809978211&amp;postID=9037822047110737595' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/9037822047110737595'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/9037822047110737595'/><link rel='alternate' type='text/html' href='http://oracledbs.blogspot.com/2008/01/practice-other-functions.html' title='Practice OTHER FUNCTIONS'/><author><name>Real Time Scenario</name><uri>http://www.blogger.com/profile/11930020132547308855</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2967271806809978211.post-1974459528905476357</id><published>2008-01-22T22:44:00.000-08:00</published><updated>2008-01-22T22:48:38.395-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Practicce CHARACTER FUNCTIONS'/><title type='text'>Practicce CHARACTER FUNCTIONS</title><content type='html'>&lt;div style="text-align: center;"&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&gt;&gt;&gt;Previous&gt;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;&lt;u&gt;&lt;strong&gt;CHARACTER FUNCTIONS:&lt;/strong&gt; &lt;/u&gt;These functions operate on  character data. &lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt;&lt;strong&gt;UPPER( str) :&lt;/strong&gt;  It converts all letters in the given string  “str” into Upper case.&lt;/p&gt; &lt;p&gt;SQL&gt; SELECT UPPER('abcDEfg') FROM  DUAL;&lt;br /&gt;UPPER('&lt;br /&gt;-------&lt;br /&gt;ABCDEFG&lt;br /&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;LOWER(str):&lt;/strong&gt;  It  converts all the letters in the given string  “str” into Lower Case.&lt;/p&gt; &lt;p&gt;SQL&gt; SELECT LOWER('ABCDEfg') FROM  DUAL;&lt;br /&gt;LOWER('&lt;br /&gt;-------&lt;br /&gt;abcdefg&lt;/p&gt; &lt;p&gt;&lt;strong&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;INITCAP(str):&lt;/strong&gt; It converts first letter of every word in the  given string “str” into Upper Case and remaining letters into lower case. It is  like proper function in FoxPro.&lt;/p&gt; &lt;p&gt;SQL&gt; SELECT INITCAP('ABCDEF') FROM DUAL;&lt;/p&gt; &lt;p&gt;INITCA&lt;br /&gt;------&lt;br /&gt;Abcdef&lt;/p&gt; &lt;p&gt;&lt;strong&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;LENGTH(str) &lt;/strong&gt;: This function returns the number of characters  in the given string (including spaces)&lt;br /&gt;&lt;/p&gt;&lt;p&gt;SQL&gt; SELECT LENGTH('ABCD') FROM  DUAL;&lt;/p&gt; &lt;p&gt;LENGTH('ABCD')&lt;br /&gt;--------------&lt;br /&gt;             4&lt;/p&gt; &lt;p&gt;SQL&gt; SELECT LENGTH('AB CD') FROM DUAL;&lt;/p&gt; &lt;p&gt;LENGTH('ABCD')&lt;br /&gt;--------------&lt;br /&gt;              5&lt;/p&gt; &lt;p&gt;&lt;strong&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;SUBSTR(str, m, n) :&lt;/strong&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Will extract  “n” characters from the  given string starting from&lt;br /&gt;“m th” position.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;SQL&gt;  SELECT  SUBSTR('ABCDEFG',2,3) FROM DUAL&lt;br /&gt;SUB&lt;br /&gt;---&lt;br /&gt;BCD&lt;br /&gt;&lt;/p&gt;&lt;p&gt;SQL&gt; SELECT  SUBSTR('ABCDEF',1,3) FROM DUAL&lt;br /&gt;SUB&lt;br /&gt;---&lt;br /&gt;ABC&lt;br /&gt;INSTR(string, str): It  displays the location of  “str” in the given string “string” .&lt;/p&gt; &lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;SQL&gt; SELECT INSTR('TRYING TO KEEP THE THINGS AS SIMPLE AS POSSIBLE','AS')  FROM  DUAL;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;INSTR('&lt;br /&gt;-----------------------------------------------------&lt;br /&gt;        27&lt;/p&gt; &lt;p&gt;&lt;strong&gt;INSTR(string, str, m, n&lt;/strong&gt;):&lt;br /&gt;&lt;/p&gt;&lt;p&gt;It displays nth occurrence of   “str” in the  string “string” starting from “m”.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;SQL&gt; SELECT INSTR('TRYING  TO KEEP THE THINGS AS SIMPLE AS POSSIBLE','AS',1,2) FROM  DUAL&lt;br /&gt;&lt;/p&gt;&lt;p&gt;INSTR(&lt;br /&gt;------------------------&lt;br /&gt;       37&lt;/p&gt; &lt;p&gt;&lt;br /&gt;&lt;strong&gt;Note &lt;/strong&gt;: DUAL IS A TABLE WITH 1 COLUMN AND 1 ROW OF DATA  IN IT.&lt;/p&gt; &lt;p&gt;SQL &gt; DESC DUAL&lt;br /&gt;&lt;/p&gt;&lt;p&gt; Name                                      Null?     Type&lt;br /&gt; ----------------------------------------- --------  -&lt;br /&gt; DUMMY                                              VARCHAR2(1)&lt;/p&gt; &lt;p&gt;SQL &gt; SELECT * FROM DUAL;&lt;/p&gt; &lt;p&gt;DUMMY&lt;br /&gt;-&lt;br /&gt;X&lt;/p&gt; &lt;p&gt;&lt;strong&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;LPAD() &lt;/strong&gt;:&lt;br /&gt;&lt;/p&gt;&lt;p&gt;This function is used to left pad the the given  string with specified character or string.&lt;/p&gt; &lt;p&gt;SQL &gt; SELECT LPAD('BCD',4,'A') FROM DUAL;&lt;/p&gt; &lt;p&gt;LPAD&lt;br /&gt;----&lt;br /&gt;ABCD&lt;/p&gt; &lt;p&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-weight: bold;"&gt;Explanation: &lt;/span&gt;To the given string "BCD" add "A" to the left necessary number  of times to make it a string of 4 characters.&lt;/p&gt; &lt;p&gt;SQL &gt; SELECT LPAD('BCD',5,'A') FROM  DUAL;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;LPAD(&lt;br /&gt;-----&lt;br /&gt;AABCD&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-weight: bold;"&gt;Explanation:&lt;/span&gt; To the given string "BCD" add  "A" to the left necessary number of times to make it a string of 5  characters.&lt;/p&gt; &lt;p&gt;SQL &gt; SELECT LPAD('BCD',3,'A') FROM DUAL;&lt;/p&gt; &lt;p&gt;LPA&lt;br /&gt;---&lt;br /&gt;BCD&lt;/p&gt; &lt;p&gt;&lt;span style="font-weight: bold;"&gt;Explanation:&lt;/span&gt; To the given string "BCD" add "A" to the left necessary number  of times to make it a string of 3 characters.&lt;/p&gt;&lt;p&gt;SQL &gt; SELECT LPAD(' ',ROWNUM,'*') FROM EMP;&lt;/p&gt; &lt;p&gt;LPAD('',ROWNUM,'*')&lt;br /&gt;-----------------------------------------------------------------&lt;/p&gt; &lt;p&gt;*&lt;br /&gt;**&lt;br /&gt;***&lt;br /&gt;****&lt;br /&gt;*****&lt;br /&gt;******&lt;br /&gt;*******&lt;br /&gt;********&lt;br /&gt;*********&lt;br /&gt;**********&lt;br /&gt;***********&lt;br /&gt;************&lt;br /&gt;*************&lt;/p&gt;&lt;p&gt;&lt;strong&gt;RPAD()&lt;/strong&gt;: This function is used to left pad the the given  string with specified character or string.&lt;/p&gt; &lt;p&gt;SQL &gt; SELECT RPAD('BILL ' , 12 , 'CLINTON') FROM DUAL;&lt;/p&gt; &lt;p&gt;RPAD('BILL',&lt;br /&gt;------------&lt;br /&gt;BILL CLINTON&lt;/p&gt; &lt;p&gt;&lt;br /&gt;&lt;strong&gt;LTRIM()&lt;/strong&gt;: This function removes specified string from the  given string if it is there to the left of given string.&lt;/p&gt; &lt;p&gt;SQL &gt; SELECT LTRIM('GEORGE BUSH', 'GEORGE') FROM DUAL;&lt;/p&gt; &lt;p&gt;LTRIM&lt;br /&gt;-----&lt;br /&gt; BUSH&lt;/p&gt; &lt;p&gt;&lt;strong&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;RTRIM()&lt;/strong&gt;: This function removes specified string from the  given string if it is there to the right of given string.&lt;/p&gt; &lt;p&gt;SQL &gt; SELECT RTRIM('TONY BLAIR', 'AIR') FROM DUAL;&lt;/p&gt; &lt;p&gt;RTRIM('&lt;br /&gt;-------&lt;br /&gt;TONY BL&lt;/p&gt; &lt;p&gt;&lt;span style="font-weight: bold;"&gt;ASCII():&lt;/span&gt; Displays equivalent ASCII value of a character.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;SQL &gt; SELECT  ASCII('A') FROM DUAL;&lt;/p&gt; &lt;p&gt;ASCII('A')&lt;br /&gt;----------&lt;br /&gt;        65&lt;/p&gt; &lt;p&gt;&lt;br /&gt;SQL &gt;SELECT TRANSLATE('JOHN','H','N') FROM DUAL;&lt;/p&gt; &lt;p&gt;TRAN&lt;br /&gt;----&lt;br /&gt;JONN&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style="text-align: center;"&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;&gt;&gt;&gt;Next&gt;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="text-align: center;"&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="text-align: center;"&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2967271806809978211-1974459528905476357?l=oracledbs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracledbs.blogspot.com/feeds/1974459528905476357/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2967271806809978211&amp;postID=1974459528905476357' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/1974459528905476357'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/1974459528905476357'/><link rel='alternate' type='text/html' href='http://oracledbs.blogspot.com/2008/01/practicce-character-functions.html' title='Practicce CHARACTER FUNCTIONS'/><author><name>Real Time Scenario</name><uri>http://www.blogger.com/profile/11930020132547308855</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2967271806809978211.post-4368093759889269096</id><published>2008-01-22T22:37:00.000-08:00</published><updated>2008-01-22T22:44:00.777-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Practice Numeric Functions'/><title type='text'>Practice Numeric Functions</title><content type='html'>&lt;div style="text-align: center;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;br /&gt;&gt;&gt;&gt;Previous&gt;&gt;&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;p&gt;&lt;u&gt;&lt;strong&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/u&gt;&lt;/p&gt;&lt;p&gt;&lt;u&gt;&lt;strong style="color: rgb(153, 0, 0);"&gt;Numeric Functions&lt;/strong&gt;:&lt;/u&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;These functions operate on Numeric  data hence is the name.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; Argument “num” in the following functions is any  float-valued number.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-weight: bold;"&gt;ABS(num): &lt;/span&gt;Returns absolute value of the given  number.(i.e.  Always positive value)&lt;/p&gt; &lt;p&gt;SQL&gt; SELECT ABS(10) FROM DUAL;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;   ABS(10)&lt;br /&gt;----------&lt;br /&gt;        10&lt;br /&gt;&lt;/p&gt;&lt;p&gt;SQL&gt; SELECT ABS(-10) FROM DUAL;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;  ABS(-10)&lt;br /&gt;----------&lt;br /&gt;        10&lt;br /&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;CEIL(num):&lt;/strong&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;It returns the smallest integer greater than  the given number.&lt;/p&gt; &lt;p&gt;SQL&gt; SELECT CEIL(123.456) FROM DUAL;&lt;/p&gt; &lt;p&gt;CEIL(123.456)&lt;br /&gt;-------------&lt;br /&gt;          124&lt;br /&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;FLOOR(num)&lt;/strong&gt;:&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;It returns the largest integer smaller than  the given value.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;SQL&gt; SELECT FLOOR(123.456) FROM DUAL;&lt;/p&gt; &lt;p&gt;FLOOR(123.456)&lt;br /&gt;--------------&lt;br /&gt;          123&lt;br /&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;LN(num)  &lt;/strong&gt;:&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;It returns natural logarithm value of “num” .&lt;/p&gt; &lt;p&gt;SQL&gt; SELECT LN(10) FROM DUAL;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;     LN(10)&lt;br /&gt;----------&lt;br /&gt;2.30258509&lt;/p&gt; &lt;p&gt;&lt;strong&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;LOG(m, n)&lt;/strong&gt;:&lt;br /&gt;&lt;/p&gt;&lt;p&gt;It returns logarithm of  “n”  with base  “m”.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;SQL&gt; SELECT LOG(100,10) FROM  DUAL;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;LOG(100,10)&lt;br /&gt;-----------&lt;br /&gt;        .5&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;SQL&gt; SELECT LOG(10,100)  FROM DUAL;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;LOG(10,100)&lt;br /&gt;-----------&lt;br /&gt;         2&lt;br /&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;MOD(m, n)  &lt;/strong&gt;:&lt;br /&gt;&lt;/p&gt;&lt;p&gt;It returns remainder of “m” divided by “n”.&lt;/p&gt; &lt;p&gt;SQL&gt; SELECT MOD(10,3) FROM DUAL;&lt;/p&gt; &lt;p&gt; MOD(10,3)&lt;br /&gt;----------&lt;br /&gt;        1&lt;br /&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;POWER(m, n)&lt;/strong&gt;:&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;It  returns value equal to “m” raised by “n”.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;SQL&gt; SELECT POWER(10,2) FROM  DUAL;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;POWER(10,2)&lt;br /&gt;-----------&lt;br /&gt;       100&lt;br /&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;ROUND(m,  n):&lt;/strong&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;It rounds the given float-valued number “m” to the “n” places after  the decimal&lt;br /&gt;&lt;/p&gt;&lt;p&gt;SQL&gt; SELECT ROUND(1.23456) FROM  DUAL;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;ROUND(1.23456)&lt;br /&gt;--------------&lt;br /&gt;             1&lt;br /&gt;&lt;/p&gt;&lt;p&gt;SQL&gt; SELECT  ROUND(1.23456,3) FROM DUAL;&lt;/p&gt; &lt;p&gt;ROUND(1.23456,3)&lt;br /&gt;----------------&lt;br /&gt;          1.235&lt;/p&gt; &lt;p&gt;&lt;strong&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;SQRT(m):&lt;/strong&gt;  It calculates square root value of number “m”&lt;/p&gt; &lt;p&gt;&lt;br /&gt;SQL&gt; SELECT SQRT(9) FROM DUAL;&lt;/p&gt; &lt;p&gt;   SQRT(9)&lt;br /&gt;----------&lt;br /&gt;        3&lt;br /&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;TRUNC(m, n)&lt;/strong&gt;:&lt;br /&gt;&lt;/p&gt;&lt;p&gt;It  truncates given float-valued number “m” to “n” places after the  decimal.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;SQL&gt; SELECT TRUNC(1.23456) FROM  DUAL;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;TRUNC(1.23456)&lt;br /&gt;--------------&lt;br /&gt;            1&lt;br /&gt;&lt;/p&gt;&lt;p&gt;SQL&gt; SELECT  TRUNC(1.23456,3) FROM DUAL;&lt;/p&gt; &lt;p&gt;TRUNC(1.23456,3)&lt;br /&gt;----------------&lt;br /&gt;            1.234&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;GREATEST(expr1, expr2, …) &lt;/strong&gt;:&lt;br /&gt;&lt;/p&gt;&lt;p&gt;It finds the greatest value  among the given expressions.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;SQL&gt; SELECT GREATEST(4,7,3,5,9,2) FROM  DUAL;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;GREATEST(4,7,3,5,9,2)&lt;br /&gt;---------------------&lt;br /&gt;                     9&lt;br /&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;LEAST(expr1, expr2, …):&lt;/strong&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;It finds the Lowest value among  the given expressions.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;SQL&gt; SELECT LEAST(4,7,3,5,9,2) FROM DUAL;&lt;/p&gt; &lt;p&gt;LEAST(4,7,3,5,9,2)&lt;br /&gt;------------------&lt;br /&gt;                  2&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;&gt;&gt;&gt;Next&gt;&gt;&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2967271806809978211-4368093759889269096?l=oracledbs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracledbs.blogspot.com/feeds/4368093759889269096/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2967271806809978211&amp;postID=4368093759889269096' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/4368093759889269096'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/4368093759889269096'/><link rel='alternate' type='text/html' href='http://oracledbs.blogspot.com/2008/01/practice-numeric-functions.html' title='Practice Numeric Functions'/><author><name>Real Time Scenario</name><uri>http://www.blogger.com/profile/11930020132547308855</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2967271806809978211.post-230900071607927296</id><published>2008-01-22T22:30:00.000-08:00</published><updated>2008-01-22T22:37:30.494-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SQL FUNCTIONS-Expressions'/><title type='text'></title><content type='html'>&lt;div style="text-align: center;"&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;&gt;&gt;&gt;Previous&gt;&gt;&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;Restricting and Sorting Data" covers the following topics. &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/strong&gt;WHERE Clause  - Comparison Operators; Logical Operator; Using the Logical Operator, AND; Using  the logical Operator, OR; Using the Logical Operator, NOT; Nesting Logical  Operators; Other Comparison Keywords; Using the Keyword, LIKE; Using the  Keywords, BETWEEN...AND; Using the Keyword, IN; Using the Keyword, IS NULL ORDER  BY Clause - Using the ORDER BY Clause.&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;strong style="color: rgb(153, 0, 0);"&gt;Expressions in a SELECT statement&lt;/strong&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;:&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Arithmetic operations can  be performed using SELECT   statement as shown below.&lt;/p&gt; &lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;SQL&gt; SELECT 10+5 FROM DUAL;&lt;br /&gt;      10+5&lt;br /&gt;----------&lt;br /&gt;        15&lt;/p&gt; &lt;p&gt;SQL&gt; SELECT 10-5 FROM DUAL;&lt;br /&gt;      10-5&lt;br /&gt;----------&lt;br /&gt;         5&lt;/p&gt; &lt;p&gt;SQL&gt; SELECT 10*5 FROM DUAL;&lt;/p&gt; &lt;p&gt;      10*5&lt;br /&gt;----------&lt;br /&gt;        50&lt;/p&gt; &lt;p&gt;SQL&gt; SELECT 10/5 FROM DUAL;&lt;/p&gt; &lt;p&gt;      10/5&lt;br /&gt;----------&lt;br /&gt;         2&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style="text-align: center;"&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;&gt;&gt;&gt;Next&gt;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2967271806809978211-230900071607927296?l=oracledbs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracledbs.blogspot.com/feeds/230900071607927296/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2967271806809978211&amp;postID=230900071607927296' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/230900071607927296'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/230900071607927296'/><link rel='alternate' type='text/html' href='http://oracledbs.blogspot.com/2008/01/restricting-and-sorting-data-covers.html' title=''/><author><name>Real Time Scenario</name><uri>http://www.blogger.com/profile/11930020132547308855</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2967271806809978211.post-319096754687756801</id><published>2008-01-22T22:27:00.000-08:00</published><updated>2008-01-22T22:29:43.588-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='What are Relational Databases?'/><title type='text'>What are Relational Databases?</title><content type='html'>&lt;div style="text-align: center;"&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;br /&gt;&gt;&gt;Previous&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;&lt;b&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;Relational Databases&lt;/span&gt; &lt;/b&gt;&lt;/h2&gt;   &lt;p&gt;The relational data model comprises:&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;   &lt;ul type="disc"&gt;&lt;li&gt;relational data structure&lt;/li&gt;&lt;li&gt;relational integrity constraints &lt;/li&gt;&lt;li&gt;relational algebra or equivalent (SQL) &lt;/li&gt;&lt;/ul&gt;   &lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;• SQL is an ISO language based on relational algebra &lt;/p&gt;   &lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;• relational algebra is a mathematical formulation &lt;/p&gt;   &lt;h2&gt;&lt;br /&gt;&lt;/h2&gt;&lt;div style="text-align: center;"&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;&gt;&gt;&gt;Next&gt;&gt;&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2967271806809978211-319096754687756801?l=oracledbs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracledbs.blogspot.com/feeds/319096754687756801/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2967271806809978211&amp;postID=319096754687756801' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/319096754687756801'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/319096754687756801'/><link rel='alternate' type='text/html' href='http://oracledbs.blogspot.com/2008/01/what-are-relational-databases.html' title='What are Relational Databases?'/><author><name>Real Time Scenario</name><uri>http://www.blogger.com/profile/11930020132547308855</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2967271806809978211.post-7948252178768729850</id><published>2008-01-22T22:25:00.000-08:00</published><updated>2008-01-22T22:27:07.102-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='What are Dabase Models ?'/><title type='text'>What are DATABASE Models?</title><content type='html'>&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;div style="text-align: center;"&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&gt;&gt;previous&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;h2 style="color: rgb(153, 0, 0);"&gt;&lt;br /&gt;&lt;/h2&gt;&lt;h2 style="color: rgb(153, 0, 0);"&gt;&lt;b&gt;Database Models&lt;/b&gt;&lt;/h2&gt;  &lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;A data model comprises &lt;/p&gt;  &lt;ul type="disc"&gt;&lt;li&gt;a data structure &lt;/li&gt;&lt;li&gt;a set of integrity constraints &lt;/li&gt;&lt;li&gt;operations associated with the data structure &lt;/li&gt;&lt;/ul&gt;  &lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Examples of data models include: &lt;/p&gt;  &lt;ul type="disc"&gt;&lt;li&gt;hierarchic &lt;/li&gt;&lt;li&gt;network &lt;/li&gt;&lt;li&gt;relational &lt;/li&gt;&lt;/ul&gt;  &lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Models other than the relational database module used to be quite popular. Each model type is appropriate to particular types of problem. The Relational model type is the most popular in use today, and the other types are not discussed further. &lt;/p&gt;  &lt;h2&gt;&lt;br /&gt;&lt;/h2&gt;&lt;div style="text-align: center;"&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;&gt;&gt;&gt;Next&gt;&gt;&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2967271806809978211-7948252178768729850?l=oracledbs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracledbs.blogspot.com/feeds/7948252178768729850/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2967271806809978211&amp;postID=7948252178768729850' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/7948252178768729850'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/7948252178768729850'/><link rel='alternate' type='text/html' href='http://oracledbs.blogspot.com/2008/01/what-are-database-models.html' title='What are DATABASE Models?'/><author><name>Real Time Scenario</name><uri>http://www.blogger.com/profile/11930020132547308855</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2967271806809978211.post-6085330534458862209</id><published>2008-01-22T22:21:00.000-08:00</published><updated>2008-01-22T22:24:51.435-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='What is SQLall about?'/><title type='text'>What is SQL?</title><content type='html'>&lt;div style="text-align: center;"&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;&gt;&gt;Previous&gt;&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;p&gt;SQL is an international standard language for manipulating relational databases. It is based on an IBM product. SQL is short for Structured Query Language. &lt;/p&gt; &lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;SQL can create schemas, delete them, and change them. It can also put data into schemas and remove data. It is a data handling language, but it is not a programming language. &lt;/p&gt; &lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;SQL is a DSL (Data Sub Language), which is really a combination of two languages.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;These are the Data Definition Language (DDL) and the Data Manipulation Language (DML).&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Schema changes are part of the DDL, while data changes are part of the DML.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;We will consider both parts of the DSL in this discussion of SQL. &lt;/p&gt; &lt;h2 style="color: rgb(153, 0, 0);"&gt;&lt;br /&gt;&lt;/h2&gt;&lt;div style="text-align: center;"&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-style: italic;"&gt;&lt;br /&gt;&gt;&gt;&gt;Next&gt;&gt;&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2967271806809978211-6085330534458862209?l=oracledbs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracledbs.blogspot.com/feeds/6085330534458862209/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2967271806809978211&amp;postID=6085330534458862209' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/6085330534458862209'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/6085330534458862209'/><link rel='alternate' type='text/html' href='http://oracledbs.blogspot.com/2008/01/what-is-sql.html' title='What is SQL?'/><author><name>Real Time Scenario</name><uri>http://www.blogger.com/profile/11930020132547308855</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2967271806809978211.post-2742673057245261193</id><published>2008-01-06T12:21:00.000-08:00</published><updated>2008-01-06T12:25:29.284-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Reducing Database Fragmentation'/><title type='text'>Reducing Database Fragmentation</title><content type='html'>&lt;b style="color: rgb(204, 0, 0);"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 0, 0);"&gt;Oracle9i database admin guide says, a fragmented  database should be reorganized to make space. The solution is to make a full db  export, delete the db, recreate the db, and a full db import. Is there another  easier option?&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;p style="color: rgb(102, 0, 0);"&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;os: win2000  server&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;oracle 9.2.0.1.0&lt;/span&gt;&lt;/b&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;-----&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;Yes, there is an  easier option. Use locally managed tablespaces. Do you have a fragmentation  problem? Are you currently using locally managed or dictionary managed  tablespaces?&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;-----&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;Yes, we are  using locally managed tablespaces, does it mean I don't have to worry about  fragmentation?&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;-----&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;It means you  don't have to worry about it as much. Are you using uniform extent sizes or  system managed extent sizes? If you are using uniform extent sizes, then you  won't have any fragmentation issues. All extent sizes are the same. If you are  using system managed extent sizes then fragmentation is greatly reduced, to the  point that you shouln't have to be concerned with it. Have you identified that  you have a fragmentation issue?&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;-----&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;No we havent,  that's another problem, I don't know how to identify if we have... I will look  it up.,&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2967271806809978211-2742673057245261193?l=oracledbs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracledbs.blogspot.com/feeds/2742673057245261193/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2967271806809978211&amp;postID=2742673057245261193' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/2742673057245261193'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/2742673057245261193'/><link rel='alternate' type='text/html' href='http://oracledbs.blogspot.com/2008/01/reducing-database-fragmentation.html' title='Reducing Database Fragmentation'/><author><name>Real Time Scenario</name><uri>http://www.blogger.com/profile/11930020132547308855</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2967271806809978211.post-1145405832256730892</id><published>2008-01-06T12:13:00.000-08:00</published><updated>2008-01-06T12:15:26.647-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Best way to compare two Databases'/><title type='text'>Best way to compare two Databases</title><content type='html'>&lt;b&gt;&lt;span style="color:#ff0000;"&gt;&lt;span style="font-size:+2;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;  &lt;p style="color: rgb(153, 0, 0);"&gt;&lt;b&gt;What is the best way to compare two databases. Especially tables+columns,  indexes+columns, constraints, views, stored procedures, triggers.&lt;/b&gt;&lt;br /&gt;&lt;b&gt;It  is not about data.&lt;/b&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style="color: rgb(153, 0, 0);"&gt;&lt;b&gt;It is not possible to make a network connection to  the two databases, so a dblink is not a possible solution.&lt;/b&gt;  &lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;-------------------------  &lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;select table_name from s1.user_tables&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;minus&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;select table_name from  s2.user_tables&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;&amp;amp;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;vice versa&lt;/span&gt; &lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;&amp;amp;&amp;amp;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;for all the  other objects in question write sql the like&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;or use dbms_metadata for both schemas and then use your  favourite editor to compare the files will all that ddl included&lt;/span&gt; &lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;or take an exp from both schemas&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;imp &lt;u&gt;/&lt;p&gt;@sid file=your.dmp fromuser=s1 show=yes  log=s1.log&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;imp &lt;u&gt;/&lt;p&gt;@sid  file=your.dmp fromuser=s2 show=yes log=s2.log&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;then compare the logs and retrieve the  differences&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;-------------------------  &lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Use OEM Change Management to take the diff between two databases. Of course  you would need OMS if want to take snapshots, but for simple comparison - it's  not neccessary.,,&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2967271806809978211-1145405832256730892?l=oracledbs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracledbs.blogspot.com/feeds/1145405832256730892/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2967271806809978211&amp;postID=1145405832256730892' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/1145405832256730892'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/1145405832256730892'/><link rel='alternate' type='text/html' href='http://oracledbs.blogspot.com/2008/01/best-way-to-compare-two-databases.html' title='Best way to compare two Databases'/><author><name>Real Time Scenario</name><uri>http://www.blogger.com/profile/11930020132547308855</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2967271806809978211.post-8654601459295600091</id><published>2008-01-06T12:08:00.000-08:00</published><updated>2008-01-06T12:12:59.697-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Database not Opening'/><title type='text'>Database not Opening</title><content type='html'>&lt;b&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;  &lt;p style="color: rgb(153, 51, 0);"&gt;&lt;b&gt;We have an amazing situation that we don't have the lastdays backup (as  backup was not properly taken up)&lt;/b&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style="color: rgb(153, 51, 0);"&gt;&lt;b&gt;The database gets mounted but don't  get opened as one of the data file is missing.&lt;/b&gt;&lt;br /&gt;&lt;b&gt;Is there any way to  recover the datafile and make the oracle server live once again.&lt;/b&gt;  &lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Good question! There are ways to bring the DB up.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;*********&lt;br /&gt;&lt;/p&gt;&lt;p&gt;SVRMGR&gt; alter database datafile '/u01/oradata/ORCL/data/users01.dbf'  offline drop;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;SVRMGR&gt; alter database open;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;SVRMGR&gt; drop tablespace  users including contents;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;*********&lt;br /&gt;&lt;/p&gt;&lt;p&gt;In the first stmt you can either use  DROP or just use OFFLINE.It totally depends on what kind of data is out in that  datafile.If un-necessary data then just drop it...if u happen to have valuable  data then you can bring it offline and try to recover the DB.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Also you  haven't mentioned if you are running a COLD or HOT bkp ?&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Do you at least  have an EXPORT.dmp of the tablespace?&lt;br /&gt;&lt;/p&gt;&lt;p&gt;If you have then just export the  Tablespace.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;I am not sure this might workout for your scenario but it may  bring the DB up for now.  &lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;Thanks a lot , by taking datafiles offline , server could be opened and is  now live.&lt;/b&gt;&lt;br /&gt;&lt;b&gt;but all the files taken offline are showing files 0 kb  size.&lt;/b&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;Was it due to virus or anyother reason?&lt;/b&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;and these  files now require auto recovery.&lt;/b&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;can these files be repaired now&lt;/b&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;However thanks for the advice&lt;/b&gt;  &lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;I ran the following command and the output came like this&lt;br /&gt;Can you explain  me the reason for the following output and also how the files can be recovered.  &lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;SQL&gt; set autorecovery on;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;SQL&gt; recover automatic datafile 11;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;ORA-00283: recovery session canceled due to errors&lt;br /&gt;&lt;/p&gt;&lt;p&gt;ORA-01157: cannot  identify/lock data file 11 - see DBWR trace file&lt;br /&gt;&lt;/p&gt;&lt;p&gt;ORA-01110: data file 11:  'E:\ORACLE\ORADATA\HHML\D_HH_ATEND.ORA'  &lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;Seems like the only option in your scenario would be dropping the  tablespace and&lt;br /&gt;re-creating a new one.&lt;/b&gt;  &lt;/p&gt;&lt;p&gt;&lt;b&gt;If you happen to have an export dump for the tablespace or objects in that  tspace just import them after creating a new ts.&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2967271806809978211-8654601459295600091?l=oracledbs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracledbs.blogspot.com/feeds/8654601459295600091/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2967271806809978211&amp;postID=8654601459295600091' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/8654601459295600091'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/8654601459295600091'/><link rel='alternate' type='text/html' href='http://oracledbs.blogspot.com/2008/01/database-not-opening.html' title='Database not Opening'/><author><name>Real Time Scenario</name><uri>http://www.blogger.com/profile/11930020132547308855</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2967271806809978211.post-7220245962767003056</id><published>2008-01-06T11:20:00.000-08:00</published><updated>2008-01-06T11:25:46.695-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Datafiles Efficiency: More Files vs Increase the Size'/><title type='text'>Datafiles Efficiency: More Files vs Increase the Size</title><content type='html'>&lt;b&gt;&lt;span style="color:#cc0000;"&gt;&lt;span style="font-size:+2;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;  &lt;p style="color: rgb(153, 51, 0);"&gt;&lt;b&gt;Which is more efficient; adding more data files or  increasiong the size of the data files of a tablespace?&lt;/b&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style="color: rgb(153, 51, 0);"&gt;&lt;b&gt;Running on oracle 9.2 on win 2000 server.&lt;/b&gt;  &lt;/p&gt;&lt;p&gt;It's mostly a personal preference. One thing to consider is recovery. If you  have fewer, larger files then restoring and recovering a file with a bad block  will take longer than if you had more, smaller files.  &lt;/p&gt;&lt;p&gt;If you are not using raid then it is better to spread the data on multiple  files on multiple disks.  &lt;/p&gt;&lt;p&gt;It depends what kind is your storage: local disks or RAID  &lt;/p&gt;&lt;p&gt;For local disks - you want to have many datafiles on as much local disks as  possible  &lt;/p&gt;&lt;p&gt;For RAID - it really doesn't matter. The datafiles are stripped anyway. it's  a more for convenience not to have huge datafiles, since if you have to move  them latter it's harder to find 20 GB disk space than 5 chunks of 4GB.  &lt;/p&gt;&lt;p&gt;If you are going to be using RAID-5 (which is common), I cannot see how  chopping up your database will help a lot. Unless you have multiple ranks of  RAID-5 storage, all your data is stored in one big blob over which you have  little physical control, if any.  &lt;/p&gt;&lt;p&gt;I usually separate my table-tablespaces and index-tablespaces into different  tablespaces and subtending datafiles, more of a matter of management than of  performance, since I am not a big fan of self-extending Oracle storage.  &lt;/p&gt;&lt;p&gt;RAID-5 automatically scatters your data when it is stored; it is part of its  reliability functions and also what can help your performance in queries. If I  were you, I would separate the database logically, and not arbitrarily separate  the storage on physical boundaries, given they are meaningless in the RAID-5  environment unless you have multiple controllers and RAID ranks.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2967271806809978211-7220245962767003056?l=oracledbs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracledbs.blogspot.com/feeds/7220245962767003056/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2967271806809978211&amp;postID=7220245962767003056' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/7220245962767003056'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/7220245962767003056'/><link rel='alternate' type='text/html' href='http://oracledbs.blogspot.com/2008/01/datafiles-efficiency-more-files-vs.html' title='Datafiles Efficiency: More Files vs Increase the Size'/><author><name>Real Time Scenario</name><uri>http://www.blogger.com/profile/11930020132547308855</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2967271806809978211.post-8324987304965200626</id><published>2008-01-06T10:46:00.000-08:00</published><updated>2008-01-06T11:14:11.904-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Oracle Service Consuming Lot of CPU Resource'/><title type='text'>Oracle Service Consuming Lot of CPU Resource</title><content type='html'>&lt;b&gt;&lt;span style="color:#cc0000;"&gt;&lt;span style="font-size:+2;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;  &lt;p style="color: rgb(102, 0, 0);"&gt;&lt;b&gt;System Config :&lt;/b&gt;&lt;br /&gt;&lt;b&gt;OS : Win 2000 A.S&lt;/b&gt;&lt;br /&gt;&lt;b&gt;Oracle  11.5.8&lt;/b&gt;&lt;br /&gt;&lt;b&gt;Rdbms : 8.1.7&lt;/b&gt;  &lt;/p&gt;&lt;p style="color: rgb(102, 0, 0);"&gt;&lt;b&gt;Usaully my Oracle use to work very good but some times  once in a blue moon , when I restarted my Database after performing a nightly  backup , it startup quickly but when I look into the Task Manager , it shows  Oracle.exe service is consuming a lot of CPU ( 70 – 80 % ) even wen no user is  connected , usually it won't.&lt;/b&gt;  &lt;/p&gt;&lt;p style="color: rgb(102, 0, 0);"&gt;&lt;b&gt;Because of this behavior my Oracle Applicatrion  services takes up a long time to get UP.  And after sometime Users starts  complaining that Application is very slow.  I didn't understand what background  process is running that is consuming a lot of CPU .&lt;/b&gt;  &lt;/p&gt;&lt;p style="color: rgb(102, 0, 0);"&gt;&lt;b&gt;I was told to create a statspack but since I am new to  DBA, can you pls. guide me how to create a statspack report.&lt;/b&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;Not getting it up quick enough is a real  problem.&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;It could be a couiple of things. First, it takes time for  your cache to "warm up". Initial database queries will take longer to run  because of this. Second, maybe your database is not being brought down cleanly  and it takes some time for SMON to clean things up.&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;Either way, I'd look at not using a cold  backup.&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p style="color: rgb(153, 0, 0);"&gt;&lt;b&gt;Creating STATSPACK:&lt;/b&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;1. Create a tablespace for this purpose called perfstat  or any good name&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;2. Run catdbsyn.sql dbmsspool.sql&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;Now you must understand the data collection level. Each  collection is in one of this level:&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;a. Level  0&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;b. Level 5&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;c.  Level 6&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;d. Level 7&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;e. Level 10&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;- Study the STATSPACK architecture -. Very  important&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;3. Do a snapshot to capture the RAM structure&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;SQL&gt; exec statspack.snap;&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p style="color: rgb(153, 51, 0);"&gt;&lt;span style="font-size:130%;"&gt;&lt;b&gt;Statspack report is easy to see the current dabase  situation&lt;/b&gt;&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;1) create a tablespace of 100mb size&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;2) run the script:  oracle_home\rdbms\admin\spcreate.sql&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;It will prompt for your default tablespace then give the  above tablespace name.  After that just give the temporary tablespace name other  than system..&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;3) take some snapshots under perfstat user.&lt;/span&gt; &lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;the command will be:&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;exec  perfstat.statspack.snap&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;take as many snap shots u want within a time  interval.&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;4) now run the script&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;oracle_home\rdbms\admin\spreport.sql&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;it will ask for your destination and name of the output report  file..&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;provide those...with to snapshot nos between which you  want to see the reports...&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;now open the report file and enjoyyyyyyyyyyyy.,,&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2967271806809978211-8324987304965200626?l=oracledbs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracledbs.blogspot.com/feeds/8324987304965200626/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2967271806809978211&amp;postID=8324987304965200626' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/8324987304965200626'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/8324987304965200626'/><link rel='alternate' type='text/html' href='http://oracledbs.blogspot.com/2008/01/oracle-service-consuming-lot-of-cpu.html' title='Oracle Service Consuming Lot of CPU Resource'/><author><name>Real Time Scenario</name><uri>http://www.blogger.com/profile/11930020132547308855</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2967271806809978211.post-833592113048607688</id><published>2008-01-06T09:50:00.000-08:00</published><updated>2008-01-06T10:06:14.141-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='How to Start the Service Manager'/><title type='text'>How to Start the Service Manager</title><content type='html'>&lt;b&gt;&lt;span style="color:#ff0000;"&gt;&lt;span style="font-size:+2;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;  &lt;p style="color: rgb(102, 0, 0); font-weight: bold; font-style: italic;"&gt;I am new to oracle. I want to know how to start the  service manager and where should I give the command. What is the password for  newlly installed oracle. Please help me out.&lt;/p&gt;&lt;p style="color: rgb(102, 0, 0); font-weight: bold; font-style: italic;"&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;If you want to run SVRMGRL on UNIX then just log on to the UNIX with your  user name and password.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;1. Type SVRMGRL&lt;br /&gt;&lt;/p&gt;&lt;p&gt;2. Type connect internal&lt;br /&gt;&lt;/p&gt;&lt;p&gt;The  message will say connected. Now you are connected to Oracle. If you are new to  Oracle then make sure of you your commands, SVMGRL has a lot of power.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Now  if you are connecting to an NT machine, then you need to start the command  prompt.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;1. Type SVRMGRL&lt;br /&gt;&lt;/p&gt;&lt;p&gt;2. It will ask you for a password, this is the  same password that you created when you did the fresh install of oracle. Once  you issue a password you should be in.  &lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;Thanks for the reply but I am working on Windows NT not Unix so let me  know how to start svrmgr in it. Your help will be appreciated.&lt;/b&gt;  &lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;For NT do the following....assuming u have Oracle installed on c:drive if u  have oracle on d: e: or anyother drive just replace the c:&gt; with ur drive. &lt;br /&gt;&lt;/p&gt;&lt;p&gt;c:&gt; set ORACLE_SID=ORCL ( whatever db name u have)&lt;br /&gt;&lt;/p&gt;&lt;p&gt;c:&gt; svrmgrl &lt;br /&gt;&lt;/p&gt;&lt;p&gt;svrmgrl &gt; connect internal&lt;br /&gt;&lt;/p&gt;&lt;p&gt;svrmgrl &gt; select * from v$database; --  if Oracle not available ...do this&lt;br /&gt;&lt;/p&gt;&lt;p&gt;svrmgrl &gt; startup&lt;br /&gt;&lt;/p&gt;&lt;p&gt;svrmgrl &gt;  select * from v$database;  &lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;You need to start the Listener too...for sqlplus conectivity..&lt;br /&gt;&lt;/p&gt;&lt;p&gt;c:&gt;  lsnrctl&lt;br /&gt;&lt;/p&gt;&lt;p&gt;lsnrctl &gt; status -- if shows errors then you need to start the  listener&lt;br /&gt;&lt;/p&gt;&lt;p&gt;lsnrctl &gt; start&lt;br /&gt;&lt;/p&gt;&lt;p&gt;If you happen to have a named listener then  u need to specify the name....&lt;br /&gt;&lt;/p&gt;&lt;p&gt;lsnrctl &gt; start ORCL (whatever listener  name you have ..check listener.ora file for that)&lt;br /&gt;&lt;/p&gt;&lt;p&gt;You should be all set  &lt;/p&gt;&lt;p&gt;&lt;b&gt;But remember man, server manager "svrmgrl" is unsupported 9i onwards. You  have to use only sqlplus to get connected.&lt;/b&gt;  &lt;/p&gt;&lt;p&gt;The person who posted this query didn't mention the version  &lt;/p&gt;&lt;p&gt;&lt;b&gt;I am new to oracle. I try to connect the oracle sever 8i (8.1.7) from  windows 2000, I got error message no listner, then I try to start listner: start  orcl and got another error message:&lt;/b&gt;&lt;br /&gt;&lt;b&gt;TNS-01151: Missing listerner  name, oracle, in LISTENER.ORA&lt;/b&gt;  &lt;/p&gt;&lt;p&gt;&lt;b&gt;This is my listerner.ora&lt;/b&gt;&lt;br /&gt;&lt;b&gt;LISTENER =&lt;/b&gt; &lt;br /&gt;&lt;b&gt;(DESCRIPTION_LIST =&lt;/b&gt;&lt;br /&gt;&lt;b&gt;(DESCRIPTION =&lt;/b&gt;&lt;br /&gt;&lt;b&gt;(ADDRESS_LIST  =&lt;/b&gt;&lt;br /&gt;&lt;b&gt;(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))&lt;/b&gt;&lt;br /&gt;&lt;b&gt;)&lt;/b&gt; &lt;br /&gt;&lt;b&gt;(ADDRESS_LIST =&lt;/b&gt;&lt;br /&gt;&lt;b&gt;(ADDRESS = (PROTOCOL = TCP)(HOST = test)(PORT  = 1521))&lt;/b&gt;&lt;br /&gt;&lt;b&gt;)&lt;/b&gt;&lt;br /&gt;&lt;b&gt;)&lt;/b&gt;&lt;br /&gt;&lt;b&gt;(DESCRIPTION =&lt;/b&gt; &lt;br /&gt;&lt;b&gt;(PROTOCOL_STACK =&lt;/b&gt;&lt;br /&gt;&lt;b&gt;(PRESENTATION = GIOP)&lt;/b&gt;&lt;br /&gt;&lt;b&gt;(SESSION =  RAW)&lt;/b&gt;&lt;br /&gt;&lt;b&gt;)&lt;/b&gt;&lt;br /&gt;&lt;b&gt;(ADDRESS = (PROTOCOL = TCP)(HOST = test)(PORT =  2481))&lt;/b&gt;&lt;br /&gt;&lt;b&gt;)&lt;/b&gt;  &lt;/p&gt;&lt;p&gt;&lt;b&gt;)&lt;/b&gt;  &lt;/p&gt;&lt;p&gt;&lt;b&gt;What I need to do ? Please help.&lt;/b&gt;  &lt;/p&gt;&lt;p&gt;According to your listener.ora file you don't have a named listener so while  starting the listener you must do the following  &lt;/p&gt;&lt;p&gt;lsnrctl start -- Correct  &lt;/p&gt;&lt;p&gt;lsnrctl start orcl -- Incorrect  &lt;/p&gt;&lt;p&gt;&lt;span style="font-weight: bold; color: rgb(102, 0, 0);"&gt;NOTE :&lt;/span&gt; Only for named listener you need to start like ... lsnrctl start orcl.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2967271806809978211-833592113048607688?l=oracledbs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracledbs.blogspot.com/feeds/833592113048607688/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2967271806809978211&amp;postID=833592113048607688' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/833592113048607688'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/833592113048607688'/><link rel='alternate' type='text/html' href='http://oracledbs.blogspot.com/2008/01/how-to-start-service-manager.html' title='How to Start the Service Manager'/><author><name>Real Time Scenario</name><uri>http://www.blogger.com/profile/11930020132547308855</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2967271806809978211.post-7698647539057842331</id><published>2008-01-06T09:35:00.000-08:00</published><updated>2008-01-06T09:41:55.901-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='How to init an object type'/><title type='text'>How to init an object type</title><content type='html'>&lt;b&gt;&lt;span style="color:#ff0000;"&gt;&lt;span style="font-size:+2;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;  &lt;p style="font-weight: bold; color: rgb(102, 0, 0);"&gt;I have the following code :&lt;/p&gt;&lt;p style="font-weight: bold; color: rgb(102, 0, 0);"&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;&lt;b&gt;CREATE OR REPLACE TYPE ObjB IS OBJECT (&lt;/b&gt;&lt;br /&gt;&lt;b&gt;B1 varchar2(10)&lt;/b&gt; &lt;br /&gt;&lt;b&gt;,B2 varchar2(10)&lt;/b&gt;&lt;br /&gt;&lt;b&gt;);&lt;/b&gt;  &lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;CREATE OR REPLACE TYPE ObjC IS OBJECT (&lt;/b&gt;&lt;br /&gt;&lt;b&gt;C1 varchar2(10)&lt;/b&gt; &lt;br /&gt;&lt;b&gt;,C2 varchar2(10)&lt;/b&gt;&lt;br /&gt;&lt;b&gt;);&lt;/b&gt;  &lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;CREATE OR REPLACE TYPE ObjCArr IS VARRAY(100) OF ObjC;&lt;/b&gt;  &lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;CREATE OR REPLACE TYPE ObjA IS OBJECT (&lt;/b&gt;&lt;br /&gt;&lt;b&gt;A1 varchar2(10)&lt;/b&gt; &lt;br /&gt;&lt;b&gt;,A2 varchar2(10)&lt;/b&gt;&lt;br /&gt;&lt;b&gt;,Ab ObjB&lt;/b&gt;&lt;br /&gt;&lt;b&gt;,Ac ObjCArr&lt;/b&gt; &lt;br /&gt;&lt;b&gt;);&lt;/b&gt;  &lt;/p&gt;&lt;p&gt;&lt;b&gt;a ObjA;&lt;/b&gt;  &lt;/p&gt;&lt;p&gt;&lt;b&gt;I've tried to initialize a, but each time I have an ORA-06530  error.&lt;/b&gt;  &lt;/p&gt;&lt;p&gt;&lt;b&gt;Any idea how to initialize it using Oracle 8.1.7 ?&lt;/b&gt;  &lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;span style="color:#990000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;  &lt;/p&gt;&lt;p style="color: rgb(153, 51, 0);"&gt;&lt;span style="font-weight: bold;"&gt;If you want to initialize, use:&lt;/span&gt;&lt;/p&gt;&lt;p style="color: rgb(153, 51, 0);"&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;DECLARE a ObjA := ObjA(NULL,NULL,ObjB(NULL,NULL),ObjCArr());  &lt;/p&gt;&lt;p&gt;Note: Since element a.Ac is a VARRAY of objects ObjC, you would have to use  &lt;/p&gt;&lt;p&gt;a.Ac.EXTEND;&lt;br /&gt;a.Ac(1) := ObjC('X','Y');  &lt;/p&gt;&lt;p&gt;to add elements to VARRAY. You can not add it using:  &lt;/p&gt;&lt;p&gt;a.Ac.EXTEND;&lt;br /&gt;a.Ac(1).C1 := 'X';&lt;br /&gt;a.Ac(2).C2 := 'Y';  &lt;/p&gt;&lt;p&gt;You can use already existing a.Ac(1).C1 or a.Ac(1).C2 for existing elements  only. &lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2967271806809978211-7698647539057842331?l=oracledbs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracledbs.blogspot.com/feeds/7698647539057842331/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2967271806809978211&amp;postID=7698647539057842331' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/7698647539057842331'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/7698647539057842331'/><link rel='alternate' type='text/html' href='http://oracledbs.blogspot.com/2008/01/how-to-init-object-type.html' title='How to init an object type'/><author><name>Real Time Scenario</name><uri>http://www.blogger.com/profile/11930020132547308855</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2967271806809978211.post-3469564302709960185</id><published>2008-01-06T09:19:00.000-08:00</published><updated>2008-01-06T09:31:25.658-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Shell Script To Dynamically Generate Init.ora File'/><title type='text'>Shell Script To Dynamically Generate Init.ora File</title><content type='html'>&lt;span style="color: rgb(102, 0, 0); font-style: italic; font-weight: bold;"&gt;&lt;br /&gt;I am working on a need to clone databases..and in that I  need to write a shell script which will 'dynamically generate' the init.ora file  for target database using that of source database and a temp file which will  hold changed value of parameters.&lt;/span&gt;&lt;p style="font-weight: bold; color: rgb(102, 0, 0);"&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span style="font-weight: bold;"&gt;For example &lt;/span&gt;in temp file there is a param like:&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;db_name =targetdb&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;and in source init.ora file db_name=db1 then the shell  script should read the temp file and be able to create a new init.ora file with  changed value&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;ie db_name=targetdb (so all other  parameters that are not specified in temp file will remain same, but all  specified parameters will be changed.)&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="font-weight: bold; color: rgb(153, 0, 0);"&gt;Can you suggest some similar scripts for such  work?  &lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;--------------------------------------------/&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;Try something this:&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;CODE&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;set pages 0 term off feed off  trims on lin 132 ver off&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;def fdb='FromDB'&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;def tdb='ToDB'&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;spo  /tmp/init&amp;amp;&amp;amp;tdb.ora&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;Select  NAME||'='||replace(VALUE,'&amp;amp;&amp;amp;fdb','&amp;amp;&amp;amp;tdb')&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; From DBA_PARAMETERS;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;spo  off&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt; &lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2967271806809978211-3469564302709960185?l=oracledbs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracledbs.blogspot.com/feeds/3469564302709960185/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2967271806809978211&amp;postID=3469564302709960185' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/3469564302709960185'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/3469564302709960185'/><link rel='alternate' type='text/html' href='http://oracledbs.blogspot.com/2008/01/shell-script-to-dynamically-generate.html' title='Shell Script To Dynamically Generate Init.ora File'/><author><name>Real Time Scenario</name><uri>http://www.blogger.com/profile/11930020132547308855</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2967271806809978211.post-3755208034911799019</id><published>2008-01-06T07:36:00.000-08:00</published><updated>2008-01-06T08:54:59.587-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='How much memory is been utilized by the SGA'/><title type='text'>How much memory is been utilized by the SGA</title><content type='html'>&lt;b&gt;&lt;span style="color:#ff0000;"&gt;&lt;span style="font-size:+2;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;  &lt;p style="color: rgb(153, 0, 0);"&gt;&lt;b&gt;We are running SAP 4.6c with ORACLE 9.2.0.5 on AIX.  Database is configured with Dynamic SGA, and we have set SGA_MAX_SIZE  also.&lt;/b&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style="color: rgb(153, 0, 0);"&gt;&lt;b&gt;When we look at the memory  management at OS level it shows high utilization of memory.&lt;/b&gt; &lt;br /&gt;&lt;/p&gt;&lt;p style="color: rgb(153, 0, 0);"&gt;&lt;b&gt;We don’t know whether the memory allocated to SGA is  completely used or not.&lt;/b&gt;&lt;br /&gt;&lt;b&gt;How to find out  how much memory is been utilized by the SGA, whether it needs to be allocated  more&lt;/b&gt; &lt;b&gt;memory or can be reduced from the  SGA.&lt;/b&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;v$sga will give you the current sga stats&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;Run statspack to analyze whether you reqiure more sga or  not&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;You can also look at V$SGASTAT view. Try running the following script (note  the part about free memory):  &lt;/p&gt;&lt;p style="color: rgb(102, 0, 0);"&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="color: rgb(102, 0, 0);"&gt;&lt;span style="font-weight: bold;"&gt;CODE&lt;/span&gt; &lt;/p&gt;&lt;pre&gt;set verify off&lt;br /&gt;set pagesize 23&lt;br /&gt;set linesize 80&lt;br /&gt;set pause on&lt;br /&gt;set pause 'Hit enter to continue'&lt;br /&gt;set feedback off&lt;br /&gt;set showmode off&lt;br /&gt;set echo off&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;col num              format 999      heading "Nbr"&lt;br /&gt;col name             format a20      heading "Name"&lt;br /&gt;col type             format 999      heading "Type"&lt;br /&gt;col value            format a10      heading "Value"&lt;br /&gt;col meg              format 99.99    heading "Size|Meg"&lt;br /&gt;col isdefault        format a10      heading "IsDefault"&lt;br /&gt;TTITLE "SHARED POOL PARAMETERS (DICTIONARY AND LIBRARY CACHE)"&lt;br /&gt;select num, name, type, value, (to_number(value) / 1024) / 1024 meg,&lt;br /&gt;isdefault&lt;br /&gt;from v$parameter&lt;br /&gt;where name = 'shared_pool_size';&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;col AA format 99.99    heading "Size MB"&lt;br /&gt;col BB format 99.99    heading "Free MB"&lt;br /&gt;col CC format 99.99    heading "% Free"&lt;br /&gt;col DD format 99999999 heading "Executions"&lt;br /&gt;col EE format 999999   heading "Reloads"&lt;br /&gt;col FF format 999.99   heading "% Reload"&lt;br /&gt;col GG format a20        heading "Parameter"&lt;br /&gt;col HH format 99,999,999 heading "Count|(entries)"&lt;br /&gt;col II format 99,999,999 heading "Usage|(valid entries)"&lt;br /&gt;col JJ format 99,999,999 heading "Gets|(memory)"&lt;br /&gt;col KK format 9,999,999  heading "Misses|(disk)"&lt;br /&gt;col LL format 99.99      heading "% Misses"&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;TTITLE CENTER 'V$PARAMETER (SHARED POOL SIZE) AND V$SGASTAT (FREE MEMORY)&lt;br /&gt;REPORT '&lt;br /&gt;select (to_number(VP.value) / 1024) / 1024 AA,&lt;br /&gt;      VS.bytes / 1048576 BB,&lt;br /&gt;      (VS.bytes / to_number(VP.value)) * 100 CC&lt;br /&gt;from  v$parameter VP, v$sgastat VS&lt;br /&gt;where VS.name = 'free memory'&lt;br /&gt;and   VP.name = 'shared_pool_size';&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; font-style: italic; color: rgb(0, 0, 0);"&gt;PROMPT &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;PROMPT More than 5% Free = lower shared_pool_buffer parameter&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;TTITLE CENTER 'V$LIBRARYCACHE (SHARED SQL AREA) SUMMARY REPORT' STITLE&lt;br /&gt;CENTER 'V$LIBRARYCACHE (SHARED SQL AREA) SUMMARY REPORT'&lt;br /&gt;select sum(VL.pins) DD,&lt;br /&gt;      sum(VL.reloads) EE,&lt;br /&gt;      (sum(VL.reloads) / sum(VL.pins)) * 100 FF&lt;br /&gt;from v$librarycache VL;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;PROMPT&lt;br /&gt;PROMPT More than 1% Reloads = raise shared_pool_size parameter&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;TTITLE CENTER 'V$ROWCACHE ENTRIES DETAIL REPORT (DICTIONARY)'&lt;br /&gt;select parameter GG,&lt;br /&gt;      /* count HH, */&lt;br /&gt;      /* usage II, */&lt;br /&gt;      gets JJ,&lt;br /&gt;      getmisses KK,&lt;br /&gt;      (getmisses / (gets + getmisses + 1)) * 100 LL&lt;br /&gt;from v$rowcache&lt;br /&gt;order by parameter;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;PROMPT&lt;br /&gt;PROMPT Not tunable at this level of detail, provided for information&lt;br /&gt;only.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;TTITLE CENTER 'V$ROWCACHE ENTRIES SUMMARY REPORT (DICTIONARY)'&lt;br /&gt;select sum(gets) JJ,&lt;br /&gt;      sum(getmisses) KK,&lt;br /&gt;      (sum(getmisses) / (sum(gets) + sum(getmisses) + 1)) * 100 LL&lt;br /&gt;from v$rowcache;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;PROMPT&lt;br /&gt;PROMPT Not tunable at this level of detail, provided for information&lt;br /&gt;only.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;TTITLE CENTER 'V$ROWCACHE ENTRIES SUMMARY REPORT (DICTIONARY)'&lt;br /&gt;select sum(gets) JJ,&lt;br /&gt;      sum(getmisses) KK,&lt;br /&gt;      (sum(getmisses) / (sum(gets) + sum(getmisses) + 1)) * 100 LL&lt;br /&gt;from v$rowcache;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;PROMPT&lt;br /&gt;PROMPT More than 5% Misses (summary) = raise shared_pool_buffer parameter&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;exit;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2967271806809978211-3755208034911799019?l=oracledbs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracledbs.blogspot.com/feeds/3755208034911799019/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2967271806809978211&amp;postID=3755208034911799019' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/3755208034911799019'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/3755208034911799019'/><link rel='alternate' type='text/html' href='http://oracledbs.blogspot.com/2008/01/how-much-memory-is-been-utilized-by-sga.html' title='How much memory is been utilized by the SGA'/><author><name>Real Time Scenario</name><uri>http://www.blogger.com/profile/11930020132547308855</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2967271806809978211.post-9199910656186889454</id><published>2008-01-06T07:29:00.000-08:00</published><updated>2008-01-06T07:36:16.243-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Unable to Create a New Instance'/><title type='text'>Unable to Create a New Instance</title><content type='html'>&lt;b&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;  &lt;p&gt;&lt;b style="color: rgb(153, 51, 0);"&gt;I am attempting to create a new instance in my sun solaris 8 server.   I  have set the environment and prepared the scripts.  I do not have gui to perform  the db creation therefore i need to use the scripts and run from sqlplus.&lt;/b&gt;&lt;span style="color: rgb(153, 51, 0);"&gt; &lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style="color: rgb(153, 51, 0);"&gt;&lt;b&gt;it's a 9.2.0.1 database.   I have added in oratab.  However when I run  this script in sqlplus - &lt;/b&gt;&lt;span style="font-weight: bold; font-style: italic;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="color: rgb(153, 51, 0);"&gt;&lt;span style="font-weight: bold; font-style: italic;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="color: rgb(153, 51, 0);"&gt;&lt;span style="font-weight: bold; font-style: italic;"&gt;I get the following error:&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;b&gt;SQL&gt; @/oracle/ora01/app/oracle/admin/xmbdb/scripts/CreateDB.sql&lt;/b&gt;&lt;br /&gt;&lt;b&gt;Connected to an idle instance.&lt;/b&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;SQL&gt; spool  /oracle/ora01/app/oracle/product/9.2.0/assistants/dbca/logs/CreateDB.&lt;/b&gt;&lt;br /&gt;&lt;b&gt;log&lt;/b&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;SQL&gt; startup nomount  pfile="/oracle/ora01/app/oracle/admin/xmbdb/pfile/init.ora"&lt;/b&gt;&lt;br /&gt;&lt;b&gt;;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;LRM-00109: could not open parameter file  '/oracle/ora01/app/oracle/admin/xmbdb/p&lt;/b&gt;&lt;br /&gt;&lt;b&gt;file/init.ora'&lt;/b&gt;&lt;br /&gt;&lt;b&gt;ORA-01078: failure in processing system parameters&lt;/b&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;SQL&gt;  CREATE DATABASE xmbdb&lt;/b&gt;&lt;br /&gt;&lt;b&gt;2 MAXINSTANCES 1&lt;/b&gt;&lt;br /&gt;&lt;b&gt;3 MAXLOGHISTORY  1&lt;/b&gt;&lt;br /&gt;&lt;b&gt;4 MAXLOGFILES 5&lt;/b&gt;&lt;br /&gt;&lt;b&gt;5 MAXLOGMEMBERS 5&lt;/b&gt;&lt;br /&gt;&lt;b&gt;6  MAXDATAFILES 100&lt;/b&gt;&lt;br /&gt;&lt;b&gt;7 DATAFILE  '/oracle/ora02/oradata/xmbdb/system01.dbf' SIZE 325M REUSE AUTOEXT&lt;/b&gt;&lt;br /&gt;&lt;b&gt;END ON NEXT 10240K MAXSIZE UNLIMITED&lt;/b&gt;&lt;br /&gt;&lt;b&gt;8 UNDO TABLESPACE  "UNDOTBS" DATAFILE '/oracle/ora02/oradata/xmbdb/undotbs01.d&lt;/b&gt;&lt;br /&gt;&lt;b&gt;bf' SIZE  200M REUSE AUTOEXTEND ON NEXT 5120K MAXSIZE UNLIMITED&lt;/b&gt;&lt;br /&gt;&lt;b&gt;9 CHARACTER SET  US7ASCII&lt;/b&gt;&lt;br /&gt;&lt;b&gt;10 NATIONAL CHARACTER SET AL16UTF16&lt;/b&gt;&lt;br /&gt;&lt;b&gt;11 LOGFILE  GROUP 1 '/oracle/ora02/oradata/xmbdb/redo01.log') SIZE 100M,&lt;/b&gt;&lt;br /&gt;&lt;b&gt;12 GROUP  2 ('/oracle/ora02/oradata/xmbdb/redo02.log') SIZE 100M,&lt;/b&gt;&lt;br /&gt;&lt;b&gt;13 GROUP 3  ('/oracle/ora02/oradata/xmbdb/redo03.log') SIZE 100M;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;CREATE DATABASE  xmbdb&lt;/b&gt;&lt;br /&gt;&lt;b&gt;*&lt;/b&gt;&lt;br /&gt;&lt;b&gt;ERROR at line 1:&lt;/b&gt;&lt;br /&gt;&lt;b&gt;ORA-01034: ORACLE not  available&lt;/b&gt;  &lt;/p&gt;&lt;p&gt;&lt;b&gt;SQL&gt; spool off&lt;/b&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;SQL&gt; exit;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;Disconnected&lt;/b&gt;  &lt;/p&gt;&lt;p style="color: rgb(102, 0, 0);"&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/p&gt;&lt;p style="color: rgb(102, 0, 0);"&gt;&lt;b&gt;How can I rectify this problem? Please Advice.&lt;/b&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;The problem you are encountering here is that you have a  Permission issue.  Try to check all the files you created are under the user  Oracle and dba Group.  It seems like you have some folders created under diff  user other than Oracle.When you try to aceess a folder which Oracle may not have  permissions will fail.  Just make sure all the folder and file permissions are  consistent with Oracle:dba&lt;/span&gt;  &lt;/p&gt;&lt;p style="color: rgb(102, 0, 0);"&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/p&gt;&lt;p style="color: rgb(102, 0, 0);"&gt;&lt;b&gt;I have checked the permissions for the folders - they  all belong to oracle user.  DoIi need to create udump, bdump, cdump and pfile  folders and put in the init.ora file into pfile folder before running the  scripts?&lt;/b&gt;  &lt;/p&gt;&lt;p&gt;There's no need to create all the dump folders. They are included in the  init.ora file by default...unless you are trying to create your own init.ora  file.  Its always better to use an existing init.ora file of other db and modify  accordingly.  Try that method and run the script again.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2967271806809978211-9199910656186889454?l=oracledbs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracledbs.blogspot.com/feeds/9199910656186889454/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2967271806809978211&amp;postID=9199910656186889454' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/9199910656186889454'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/9199910656186889454'/><link rel='alternate' type='text/html' href='http://oracledbs.blogspot.com/2008/01/unable-to-create-new-instance.html' title='Unable to Create a New Instance'/><author><name>Real Time Scenario</name><uri>http://www.blogger.com/profile/11930020132547308855</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2967271806809978211.post-305187118532561422</id><published>2008-01-06T07:27:00.000-08:00</published><updated>2008-01-06T07:29:32.603-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Unable to locate statement causing error'/><title type='text'>Unable to locate statement causing error</title><content type='html'>&lt;b&gt;&lt;span style="color:#ff0000;"&gt;&lt;span style="font-size:+2;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;  &lt;p&gt;&lt;b&gt;&lt;span style="color:#000000;"&gt;When I ran the procedure below, I am running into the  following error:&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color:#000000;"&gt;The error is ORA-00936:  missing expression&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color:#000000;"&gt;I tried to put  DBMS_OUTPUT.PUT_LINE statements to see where it is failing. I received the  following output&lt;/span&gt;&lt;/b&gt;  &lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;span style="color:#000000;"&gt;SQL&gt; exec proc_load_user_privileges&lt;/span&gt;&lt;/b&gt; &lt;br /&gt;&lt;b&gt;&lt;span style="color:#000000;"&gt;The error is 6&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color:#000000;"&gt;The error is 1&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color:#000000;"&gt;The error is  3&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color:#000000;"&gt;The error is 1&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color:#000000;"&gt;The error is 3&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color:#000000;"&gt;The error is  1&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color:#000000;"&gt;The error is 3&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color:#000000;"&gt;The error is 1&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color:#000000;"&gt;The error is  3&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color:#000000;"&gt;The error is 1&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color:#000000;"&gt;The error is 3&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color:#000000;"&gt;The error is  1&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color:#000000;"&gt;The error is 3&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color:#000000;"&gt;The error is 1&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color:#000000;"&gt;The error is  3&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color:#000000;"&gt;The error is 1&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color:#000000;"&gt;The error is 3&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color:#000000;"&gt;The error is  1&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color:#000000;"&gt;The error is 3&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color:#000000;"&gt;The error is 1&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color:#000000;"&gt;The error is  3&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color:#000000;"&gt;The error is 1&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color:#000000;"&gt;The error is 3&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color:#000000;"&gt;The error is  1&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color:#000000;"&gt;The error is 3&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color:#000000;"&gt;The error is 1&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color:#000000;"&gt;The error is  3&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color:#000000;"&gt;The error is 1&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color:#000000;"&gt;The error is 3&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color:#000000;"&gt;The error is  1&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color:#000000;"&gt;The error is 3&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color:#000000;"&gt;The error is 1&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color:#000000;"&gt;The error is  3&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color:#000000;"&gt;The error is 1&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color:#000000;"&gt;The error is 3&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color:#000000;"&gt;The error is  1&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color:#000000;"&gt;The error is 3&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color:#000000;"&gt;The error is 1&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color:#000000;"&gt;The error is  3&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color:#000000;"&gt;The error is 1&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color:#000000;"&gt;The error is 3&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color:#000000;"&gt;The error is  1&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color:#000000;"&gt;The error is 3&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color:#000000;"&gt;The error is 1&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color:#000000;"&gt;The error is  3&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color:#000000;"&gt;The error is 4&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color:#000000;"&gt;The error is 6&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color:#000000;"&gt;The error is  ORA-00936: missing expression&lt;/span&gt;&lt;/b&gt;  &lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;span style="color:#000000;"&gt;It looks like right after the loop is done, the error  is happening. How can I zero in on the statement that is causing the problems? I  tried to run all the sql statements by themselves in sql*plus and they are  working fine. I am not sure where the syntax error is. Any help would be greatly  appreciated.&lt;/span&gt;&lt;/b&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;Here is the procedure text&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;CREATE OR REPLACE PROCEDURE  proc_load_user_privileges&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;AS&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;CURSOR cur_list_of_cols&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;IS&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;SELECT column_name FROM  user_tab_columns WHERE table_name = 'TEMP_NSDA_USER_PRIVILEGE' AND column_name  NOT IN ('SUN_ID', 'NODE_ID', 'OPERATION', 'FIRST_NM', 'LAST_NM',  'FUNCTIONAL_AREA_NM');&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;CURSOR cur_temp_nsda_user_privilege&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;IS&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;SELECT  SUN_ID,NODE_ID,OPERATION,FIRST_NM,LAST_NM,FUNCTIONAL_AREA_NM FROM  TEMP_NSDA_USER_PRIVILEGE;&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;v_current_sun_id VARCHAR2(30);&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;v_current_node_id NUMBER(20);&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;v_current_privilege_nm VARCHAR2(30);&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;v_current_user_privilege_val VARCHAR2(30);&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;v_current_column_name_in VARCHAR2(30);&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;v_block_str VARCHAR2(500);&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;v_dynamic_query_handle INTEGER;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;feedback INTEGER;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;v_curr  VARCHAR2(30);&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;v_operation VARCHAR2(30);&lt;/span&gt; &lt;br /&gt;&lt;span style="color:#000000;"&gt;v_first_nm VARCHAR2(30);&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;v_last_nm VARCHAR2(30);&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;v_functional_area VARCHAR2(30);&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;BEGIN&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;FOR  rec_temp_nsda_user_priv IN cur_temp_nsda_user_privilege&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;LOOP&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;v_current_sun_id :=  rec_temp_nsda_user_priv.sun_id;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;v_current_node_id  := rec_temp_nsda_user_priv.node_id;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;v_operation  := rec_temp_nsda_user_priv.operation;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;v_first_nm  := rec_temp_nsda_user_priv.first_nm;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;v_last_nm :=  rec_temp_nsda_user_priv.last_nm;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;v_functional_area :=  rec_temp_nsda_user_priv.functional_area_nm;&lt;/span&gt;&lt;br /&gt; &lt;br /&gt;   &lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;IF v_operation = 'UPDATE' THEN&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;DELETE FROM NSDA_USER_PRIVILEGE_T&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;WHERE sun_id = v_current_sun_id;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;END IF;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;DBMS_OUTPUT.PUT_LINE('The  error is 6');&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;FOR current_col IN  cur_list_of_cols&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;LOOP&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;v_current_privilege_nm:= current_col.column_name;&lt;/span&gt;&lt;br /&gt;   &lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;v_block_str:=&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;'SELECT ' ||  v_current_privilege_nm || ' FROM TEMP_NSDA_USER_PRIVILEGE WHERE sun_id = ' ||  v_current_sun_id || ' AND node_id = ' || v_current_node_id ;&lt;/span&gt;&lt;br /&gt;   &lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;EXECUTE IMMEDIATE v_block_str INTO  v_current_user_privilege_val;&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;BEGIN&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;SELECT&lt;/span&gt; &lt;br /&gt;&lt;span style="color:#000000;"&gt;REPLACE(v_current_privilege_nm, '_', ' ')&lt;/span&gt; &lt;br /&gt;&lt;span style="color:#000000;"&gt;INTO v_current_privilege_nm&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;FROM DUAL;&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;END;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;DBMS_OUTPUT.PUT_LINE('The error is 1');&lt;/span&gt;&lt;br /&gt;   &lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;IF (v_current_user_privilege_val = 'Y')&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;THEN&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;INSERT INTO NSDA_USER_PRIVILEGE_T (sun_id, node_id,  privilege_nm) VALUES (v_current_sun_id, v_current_node_id,  v_current_privilege_nm);&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;ELSIF (v_current_user_privilege_val IS NOT NULL) AND  (v_current_user_privilege_val != 'N')&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;THEN&lt;/span&gt; &lt;br /&gt;&lt;span style="color:#000000;"&gt;v_current_user_privilege_val:=  TO_NUMBER(v_current_user_privilege_val);&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;DBMS_OUTPUT.PUT_LINE('The error is 2');&lt;/span&gt;&lt;br /&gt;   &lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;INSERT INTO NSDA_USER_PRIVILEGE_T&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;(sun_id, node_id, privilege_nm, user_privilege_value)&lt;/span&gt; &lt;br /&gt;&lt;span style="color:#000000;"&gt;VALUES&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;(v_current_sun_id,v_current_node_id,v_current_privilege_nm,v_current_user_privilege_val);&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;END IF;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;DBMS_OUTPUT.PUT_LINE('The error is 3');&lt;/span&gt;&lt;br /&gt; &lt;br /&gt;   &lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;END LOOP;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;DBMS_OUTPUT.PUT_LINE('The error is 4');&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;END LOOP;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;DBMS_OUTPUT.PUT_LINE('The error is 5');&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;EXCEPTION&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;WHEN OTHERS THEN&lt;/span&gt; &lt;br /&gt;&lt;span style="color:#000000;"&gt;DBMS_OUTPUT.PUT_LINE('The error is ' || SQLERRM);&lt;/span&gt; &lt;br /&gt;&lt;span style="color:#000000;"&gt;END proc_load_user_privileges;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2967271806809978211-305187118532561422?l=oracledbs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracledbs.blogspot.com/feeds/305187118532561422/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2967271806809978211&amp;postID=305187118532561422' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/305187118532561422'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/305187118532561422'/><link rel='alternate' type='text/html' href='http://oracledbs.blogspot.com/2008/01/unable-to-locate-statement-causing.html' title='Unable to locate statement causing error'/><author><name>Real Time Scenario</name><uri>http://www.blogger.com/profile/11930020132547308855</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2967271806809978211.post-3893160214531229798</id><published>2008-01-06T07:22:00.000-08:00</published><updated>2008-01-06T07:23:48.177-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Deleting all objects from a tablespace'/><title type='text'>Deleting all objects from a tablespace</title><content type='html'>&lt;b&gt;&lt;span style="color:#ff0000;"&gt;&lt;span style="font-size:+2;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;  &lt;p&gt;&lt;b&gt;&lt;span style="color:#000000;"&gt;Just want to know what's the best way to delete all  the objects (tables, indexes, squences, etc..) from a tablespace?&lt;/span&gt;&lt;/b&gt; &lt;br /&gt;&lt;b&gt;&lt;span style="color:#000000;"&gt;Delete the tablespace and recreate  it?&lt;/span&gt;&lt;/b&gt;  &lt;/p&gt;&lt;p&gt;Just drop the tables from the User(s) whatever exists in that tablespace.This  way u can be sure everything is removed.You don't need to drop the tablespace.   If you are using Oracle Enterprise Manager(OEM) its very simple...just click on  the database-schema-tables-select all the tables in that user and remove them  from the schema....do the same for the views/synonyms/seq...&lt;br /&gt;&lt;/p&gt;&lt;p&gt;(OR)&lt;br /&gt;&lt;/p&gt;&lt;p&gt;If you  are not having OEM then u can write a sql stm to drop the  tables/views/synonyms/....from each user individually.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;(OR)&lt;br /&gt;&lt;/p&gt;&lt;p&gt;If you are  not worried about the users and the data in it....simply drop the user which  will remove everything.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;First list out all the users in that tablespace and  proceed.  &lt;/p&gt;&lt;p&gt;&lt;b&gt;I do have OEM installed. When I try to run it, it will not let me connect.  I'm leaving the management server box blank (the database is local) and using  all the different username/password combos I can think of that oracle came  with.  Am I missing something here?&lt;/b&gt;  &lt;/p&gt;&lt;p&gt;For logon to OEM u might be using a right password but may be the  TNSNAMES.ora file have some issues.Check your sqlnet.ora file and all the tns  aliases in the tnsnames.ora file and make sure ur using .world in your host or  just the string.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Ex: system/manager@orcl.world --if sqlnet.ora has  names.default_domain=world&lt;br /&gt;Ex: system/manager@orcl --if sqlnet.ora dont have  any entry or commented for names.default_domain=world&lt;br /&gt;&lt;/p&gt;&lt;p&gt;The thing is OEM  configures itself with the TNSNAMES.ora once installed so while conecting it  only expects you to connect using uname/pwd as the host name is already picked  by it.In the worst case create a new database tree and try.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2967271806809978211-3893160214531229798?l=oracledbs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracledbs.blogspot.com/feeds/3893160214531229798/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2967271806809978211&amp;postID=3893160214531229798' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/3893160214531229798'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/3893160214531229798'/><link rel='alternate' type='text/html' href='http://oracledbs.blogspot.com/2008/01/deleting-all-objects-from-tablespace.html' title='Deleting all objects from a tablespace'/><author><name>Real Time Scenario</name><uri>http://www.blogger.com/profile/11930020132547308855</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2967271806809978211.post-2619356642802060458</id><published>2008-01-06T07:15:00.001-08:00</published><updated>2008-01-06T07:21:01.127-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Deleting duplicate rows in the table'/><title type='text'>Deleting duplicate rows in the table</title><content type='html'>&lt;b style="color: rgb(102, 0, 0);"&gt;&lt;span style="font-size:+2;"&gt;&lt;/span&gt;&lt;/b&gt;  &lt;p&gt;&lt;b style="color: rgb(153, 51, 0);"&gt;I am searching for a way to delete the duplicate records in a table..&lt;/b&gt;&lt;span style="color: rgb(153, 51, 0);"&gt;  &lt;/span&gt;&lt;br /&gt;&lt;b style="color: rgb(153, 51, 0);"&gt;Is anybody having efficient way to do it..?&lt;/b&gt;&lt;span style="color: rgb(153, 51, 0);"&gt; &lt;/span&gt;&lt;br /&gt;&lt;b&gt; &lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color:#990000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;  &lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-weight: bold; font-style: italic; color: rgb(0, 102, 0);"&gt;The command is: &lt;/span&gt;&lt;br /&gt; &lt;br /&gt;DELETE &lt;duplicate_col_name&gt; dv&lt;br /&gt;FROM  &lt;table_name&gt; a WHERE rowid &lt;&lt;br /&gt;  (SELECT MIN(rowid)&lt;br /&gt;   FROM  &lt;table_name&gt; b&lt;br /&gt;   WHERE a.dv = b.dv);&lt;br /&gt; &lt;br /&gt;&lt;/p&gt;&lt;p&gt;i.e. if the table name  is emp and the dupicate column value is ename:&lt;br /&gt; &lt;br /&gt;DELETE ename&lt;br /&gt;FROM  emp a&lt;br /&gt;WHERE rowid &lt;&lt;br /&gt;(SELECT MIN(rowid)&lt;br /&gt; FROM emp b&lt;br /&gt; WHERE  a.ename = b.ename)&lt;br /&gt; &lt;br /&gt;&lt;span style="font-weight: bold; font-style: italic; color: rgb(102, 0, 0);"&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-weight: bold; font-style: italic; color: rgb(102, 0, 0);"&gt;Another solution is: &lt;/span&gt;&lt;br /&gt; &lt;br /&gt;delete from  &lt;table_name&gt; where rowid not in (&lt;br /&gt;select max(rowid) from  &lt;table_name&gt; group by &lt;duplicate_values_field_name&gt;);&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2967271806809978211-2619356642802060458?l=oracledbs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracledbs.blogspot.com/feeds/2619356642802060458/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2967271806809978211&amp;postID=2619356642802060458' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/2619356642802060458'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/2619356642802060458'/><link rel='alternate' type='text/html' href='http://oracledbs.blogspot.com/2008/01/deleting-duplicate-rows-in-table.html' title='Deleting duplicate rows in the table'/><author><name>Real Time Scenario</name><uri>http://www.blogger.com/profile/11930020132547308855</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2967271806809978211.post-4787441066673107342</id><published>2008-01-06T07:10:00.000-08:00</published><updated>2008-01-06T07:12:27.722-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='How to Drop undo Tablespace'/><title type='text'>How to Drop undo Tablespace</title><content type='html'>&lt;b&gt;&lt;span style="color:#cc0000;"&gt;&lt;span style="font-size:+2;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;  &lt;p&gt;&lt;b&gt;&lt;span style="color:#000000;"&gt;I create a new undo tablespace, then I want to drop  the org undo ts and recreate is with a smaller size.&lt;/span&gt;&lt;/b&gt;  &lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;span style="color:#000000;"&gt;However, after switching Ii am not always able to  offline the org tablespace.&lt;/span&gt;&lt;/b&gt;  &lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;span style="color:#000000;"&gt;I get an Ora-30042:Unable to offline the undo  TS.&lt;/span&gt;&lt;/b&gt;  &lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;span style="color:#000000;"&gt;This error is always returned when using the  procedure. This is in a test db, where I'm the only one logged in (sqlplus  /nolog).&lt;/span&gt;&lt;/b&gt;  &lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;span style="color:#000000;"&gt;Lookin in de alert.log it states:&lt;/span&gt;&lt;/b&gt; &lt;br /&gt;&lt;b&gt;&lt;span style="color:#000000;"&gt;Undo tablespace 1 moved to Pending Switch-Out  State.&lt;/span&gt;&lt;/b&gt;  &lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;span style="color:#000000;"&gt;What does this mean? How can I make sure the undo TS  is not being used anymore, so I can offline it?&lt;/span&gt;&lt;/b&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;Using this command shift user UNDO and the try to drop  old one.&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;ALTER SYSTEM SET UNDO_TABLESPACE = ....&lt;/span&gt;  &lt;/p&gt;&lt;p style="font-weight: bold; color: rgb(102, 0, 0);"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style="font-weight: bold; color: rgb(102, 0, 0);"&gt;Note of cautious:  &lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;An undo tablespace can only be dropped if it is not  currently used by any instance. If the undo tablespace contains any outstanding  transactions (for example, a transaction died but has not yet been recovered),  the DROP TABLESPACE statement fails. However, since DROP TABLESPACE drops an  undo tablespace even if it contains unexpired undo information (within retention  period), you must be careful not to drop an undo tablespace if undo information  is needed by some existing queries.,,&lt;/span&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2967271806809978211-4787441066673107342?l=oracledbs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracledbs.blogspot.com/feeds/4787441066673107342/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2967271806809978211&amp;postID=4787441066673107342' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/4787441066673107342'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/4787441066673107342'/><link rel='alternate' type='text/html' href='http://oracledbs.blogspot.com/2008/01/how-to-drop-undo-tablespace.html' title='How to Drop undo Tablespace'/><author><name>Real Time Scenario</name><uri>http://www.blogger.com/profile/11930020132547308855</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2967271806809978211.post-3176447690366381784</id><published>2008-01-06T05:33:00.001-08:00</published><updated>2008-01-06T05:36:23.645-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Select Entries from Whole Week-SqlTip'/><title type='text'>Select Entries from Whole Week</title><content type='html'>&lt;b&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 0, 0);"&gt;Get all entries from "the whole week" (begin: Monday  end: Sunday) from e.g the day sysdate - 222 (today: 20.10.2004) . This means all  entries with a date between 08.03.2004 and 14.03.2004 (including the borders  !)&lt;/span&gt;&lt;/b&gt;&lt;p style="color: rgb(102, 0, 0);"&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;create or replace&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;procedure whole_week (week date) is&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;total number(6);&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;day  varchar2(20);&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;begin&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;total:=0;&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;select to_char(sysdate,'day') into day from  dual;&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;if day='montag' then&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;select sum(total) into total from s_ord where date_ordered between  week-1 and week+5;&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;else if day='dienstag' then&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;select sum(total) into total from s_ord where date_ordered between  week-2 and week+4;&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;else if day='mittwoch' then&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;select sum(total) into total from s_ord where date_ordered between  week-3 and week+3;&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;else if day='donnerstag' then&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;select sum(total) into total from s_ord where date_ordered between  week-4 and week+2;&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;else if day='freitag' then&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;select sum(total) into total from s_ord where date_ordered between  week-5 and week+1;&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;else if day='samstag' then&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;select sum(total) into total from s_ord where date_ordered between  week-6 and week;&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;else if day='sonntag' then&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;select sum(total) into total from s_ord where date_ordered between  week and week+6;&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;else&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;dbms_output.put_line('kein tag');&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;end if;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;end if;&lt;/span&gt; &lt;br /&gt;&lt;span style="color:#000000;"&gt;end if;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;end if;&lt;/span&gt; &lt;br /&gt;&lt;span style="color:#000000;"&gt;end if;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;end if;&lt;/span&gt; &lt;br /&gt;&lt;span style="color:#000000;"&gt;end if;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;dbms_output.put_line(total);&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;end;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;/&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;begin&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;whole_week(sysdate+1);&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;end;&lt;/span&gt; &lt;br /&gt;&lt;span style="color:#000000;"&gt;/&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;instead of montag you have to write monday and so  on...i've hat a german version so i've got this names for the days.&lt;/span&gt; &lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;montag is monday&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;dienstag  is tuesday&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;mittwoch is wednesday&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;donnerstag is thursday&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;freitag is  friday&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;samstag is saturday&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;sonntag is sunday&lt;/span&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2967271806809978211-3176447690366381784?l=oracledbs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracledbs.blogspot.com/feeds/3176447690366381784/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2967271806809978211&amp;postID=3176447690366381784' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/3176447690366381784'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/3176447690366381784'/><link rel='alternate' type='text/html' href='http://oracledbs.blogspot.com/2008/01/select-entries-from-whole-week.html' title='Select Entries from Whole Week'/><author><name>Real Time Scenario</name><uri>http://www.blogger.com/profile/11930020132547308855</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2967271806809978211.post-8709451620841608228</id><published>2008-01-06T05:14:00.000-08:00</published><updated>2008-01-06T05:31:04.888-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Modifying A Column Of A Table-Sql Tip'/><title type='text'>Modifying A Column Of A Table</title><content type='html'>&lt;b&gt;&lt;span style="color:#cc0000;"&gt;&lt;span style="font-size:+2;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;  &lt;p&gt;&lt;b&gt;&lt;span style="color:#000000;"&gt;I have a table lets say demo, and one of the columns  of this table is time_in_sec is of type number(38).&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;span style="color:#000000;"&gt;This table has around 20,000 rows of data.  Now I want to modify  the time_in_sec column of demo table to number (7,3) so that I can store values  like 234.987&lt;/span&gt;&lt;/b&gt;  &lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;span style="color:#000000;"&gt;All the existing datas in this column are numbers up  to maximum of 3 digit whenever I am trying to modify the column I get errors  like ORA-01440: column to be modified must be empty to decrease precision or  scale one solution to this was drop this column and add new column but I do not  want to loose existing data.&lt;/span&gt;&lt;/b&gt;  &lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;span style="color:#000000;"&gt;How to achieve the changes I want ie changing the  column type from number (38) to number (7,3)&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;   &lt;/p&gt;&lt;p style="font-weight: bold; font-style: italic; color: rgb(102, 0, 0);"&gt;CODE :  &lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;Create Table Demo_Time_In_Sec As Select Rowid Row_Id,  Time_In_Sec From Demo;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;Update Demo Set  Time_In_Sec = Null;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;Commit;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;Alter Table Demo Modify (Time_In_Sec Number(7,3));&lt;/span&gt; &lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;Update Demo U Set Time_In_Sec = (&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;Select Time_In_Sec From Demo_Time_In_Sec T&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;Where U.Rowid = T.Row_Id);&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;Commit;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;Drop Table  Demo_Time_In_Sec;&lt;/span&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2967271806809978211-8709451620841608228?l=oracledbs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracledbs.blogspot.com/feeds/8709451620841608228/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2967271806809978211&amp;postID=8709451620841608228' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/8709451620841608228'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/8709451620841608228'/><link rel='alternate' type='text/html' href='http://oracledbs.blogspot.com/2008/01/modifying-column-of-table.html' title='Modifying A Column Of A Table'/><author><name>Real Time Scenario</name><uri>http://www.blogger.com/profile/11930020132547308855</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2967271806809978211.post-6621924417665507698</id><published>2008-01-06T05:03:00.000-08:00</published><updated>2008-01-06T05:13:29.761-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Modify the Primary Key Order-sql tip'/><title type='text'>Modify the Primary Key Order</title><content type='html'>&lt;span style="font-weight: bold;color:#cc0000;" &gt;&lt;span style="font-size:+2;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;  &lt;p&gt;&lt;b&gt;&lt;span style="color:#000000;"&gt;I have created a composite primary key (a,b,c) in the  table. It has references in other table also.&lt;/span&gt;&lt;/b&gt;  &lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;span style="color:#000000;"&gt;Now I want to modify the primary key order - (b,c,a).   How to go about it?&lt;/span&gt;&lt;/b&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;You can try this sequence:&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;1) disable primary key related foreign constraint on  child table;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;2) disable primary key constaint on  present table&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;3) drop index&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;4) recreate index&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;5) enable all  disabled constraint&lt;/span&gt;  &lt;/p&gt;&lt;p style="font-weight: bold; font-style: italic; color: rgb(153, 0, 0);"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style="font-weight: bold; font-style: italic; color: rgb(153, 0, 0);"&gt;The enclosed scrip will do it:  &lt;/p&gt;&lt;p&gt;&lt;span style="font-weight: bold; font-style: italic; color: rgb(153, 0, 0);" &gt;CODE&lt;/span&gt;&lt;span style="font-weight: bold; font-style: italic; color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;FILE:  recreate_pk_ddl.sql&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;set pagesize 999 heading off verify off termout  off&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;set feedback off sqlcase upper newpage 3  rowsize 400&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;SELECT constraint_name column1,5  column2, 0 column3,&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;      'alter  table  '||table_name||' add constraint '||table_name||'_pk primary key ('&lt;/span&gt; &lt;br /&gt;&lt;span style="color:#000000;"&gt;FROM user_constraints where&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;constraint_type = 'P'&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;UNION&lt;/span&gt; &lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;SELECT constraint_name,10,position,&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;      decode(position,1,' ',',')||column_name&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;from user_cons_columns&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;where  constraint_name in (select constraint_name from user_constraints&lt;/span&gt; &lt;br /&gt;&lt;span style="color:#000000;"&gt;where constraint_type = 'P')&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;UNION&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;SELECT constraint_name,  20,99,'   )' from user_constraints&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;union&lt;/span&gt; &lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;select constraint_name, 30,99,'   using index' from  user_constraints&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;union&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;select constraint_name, 40,99,'   pctfree  10' from  user_constraints&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;union&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;select constraint_name, 50,99,'   tablespace indexes ' from  user_constraints&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;union&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;select constraint_name, 60,99,'   storage(   ' from  user_constraints&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;union&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;select constraint_name, 70,99,'   initial    ' from  user_constraints&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;union&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;select constraint_name, 80,99,'   next       ' from  user_constraints&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;union&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;select constraint_name, 90,99,'   pctincrease 0   );' from  user_constraints&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;union&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;select constraint_name, 100,99, '  ' from user_constraints&lt;/span&gt; &lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;order by 1,2,3;&lt;/span&gt; &lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2967271806809978211-6621924417665507698?l=oracledbs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracledbs.blogspot.com/feeds/6621924417665507698/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2967271806809978211&amp;postID=6621924417665507698' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/6621924417665507698'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/6621924417665507698'/><link rel='alternate' type='text/html' href='http://oracledbs.blogspot.com/2008/01/modify-primary-key-order.html' title='Modify the Primary Key Order'/><author><name>Real Time Scenario</name><uri>http://www.blogger.com/profile/11930020132547308855</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2967271806809978211.post-5574377725167528937</id><published>2008-01-06T04:15:00.000-08:00</published><updated>2008-01-06T04:50:54.236-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Renaming A Datafile'/><title type='text'>Renaming A Datafile</title><content type='html'>&lt;b&gt;&lt;span style="color:#cc0000;"&gt;&lt;span style="font-size:+2;"&gt;Renaming A Datafile&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;  &lt;p&gt;&lt;b&gt;&lt;span style="color:#000000;"&gt;I'm using Windows XP and Oracle 9i R2.  The issue are  as follows:&lt;/span&gt;&lt;/b&gt;  &lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;span style="color:#000000;"&gt;1. I found 2 strange names in the V$datafiles. They  are .ORA and logdata03 .  What I wanted is all datafiles have .DBF  extension.&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;span style="color:#000000;"&gt;2. In order to rename the file  I shutdown the database and rename the physical file (.ORA first)&lt;/span&gt;&lt;/b&gt; &lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;span style="color:#000000;"&gt;3. I think I've done something wrong here because I  do not really need to shuttdown the database, I just need to take that datafile  offline and change the name physically and in the database.&lt;/span&gt;&lt;/b&gt; &lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;span style="color:#000000;"&gt;4. Since I'm using a Laptop which is impossible to  always generate ARC files, I set my database to NO ARCHIVE  LOG.&lt;/span&gt;&lt;/b&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(153, 0, 0); font-weight: bold;font-size:100%;color:#000000;"  &gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(153, 0, 0); font-weight: bold;font-size:100%;color:#000000;"  &gt;The questions are:&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(153, 0, 0); font-weight: bold;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;span style="color:#000000;"&gt;When I wanted to take the datafile offline, I use this  command&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;span style="color:#000000;"&gt;Alter tablespace finance datafile  44 offline;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;span style="color:#000000;"&gt;But an error appears that I  supposed to have the database in ARCHIVE LOG mode.&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;span style="color:#000000;"&gt;then, I just try my luck with this syntax&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;span style="color:#000000;"&gt;ALTER TABLESPACE FINANCE DATAFILE 44 OFFLINE DROP;&lt;/span&gt;&lt;/b&gt; &lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;span style="color:#000000;"&gt;It can, then I can start renaming the datafile  again.&lt;/span&gt;&lt;/b&gt;  &lt;/p&gt;&lt;p style="color: rgb(153, 0, 0);"&gt;&lt;b&gt;1. What is the meaning of OFFLINE DROP? because at  first I thought it will take the datafile offline and Drop the datafile as if  you are deleting it.&lt;/b&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;The DROP keyword must be specified if the database is in  NOARCHIVELOG mode. The datafile is not dropped, it is flagged as either OFFLINE  or RECOVER.&lt;/span&gt;  &lt;/p&gt;&lt;p style="color: rgb(102, 0, 0);"&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/p&gt;&lt;p style="color: rgb(102, 0, 0);"&gt;&lt;b&gt;2. What actually happened to the redolog file when I  did that command?  I think that when we are going to make one of the datafile  offline, Oracle will reset all the log in the logfile after applying the changes  to that offline datafile.&lt;/b&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;When a datafile is placed offline while the database is  open, media recovery must be performed to bring the datafile back  online.&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;The online redo logs will be used to perform media  recovery before you can bring the datafile online but the redo logs are not  reset.&lt;/span&gt;  &lt;/p&gt;&lt;p style="color: rgb(153, 51, 0);"&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/p&gt;&lt;p style="color: rgb(153, 51, 0);"&gt;&lt;b&gt;3. I did this in my laptop which is me the only person  who did the transactions. what might happened if I did this in the live system  with busy transaction 24 hours?&lt;/b&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;Data in the datafile that was taken offline would not be  accessible until it is online once again. Consider the following:&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;CODE :&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="font-weight: bold;color:#000000;" &gt;Connected to:&lt;/span&gt;&lt;span style="font-weight: bold;"&gt; &lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;Oracle9i  Enterprise Edition Release 9.2.0.5.0 - Production&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;With the Partitioning, OLAP and Oracle Data Mining options&lt;/span&gt; &lt;br /&gt;&lt;span style="color:#000000;"&gt;JServer Release 9.2.0.5.0 - Production&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;SQL&gt; select log_mode from v$database;&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;LOG_MODE&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;------------&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;NOARCHIVELOG&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;SQL&gt; create tablespace test datafile  'G:\ORACLE\ORADATAIDB\TEST.DBF' size 8M&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt; 2   extent management local segment space management auto;&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;Tablespace created.&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;SQL&gt; create table test_table tablespace test as select  * from all_objects where rownum &lt;= 10000;&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;Table created.&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;SQL&gt; select count(*) from test_table;&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt; COUNT(*)&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;----------&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;    10000&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;SQL&gt; alter database datafile  'G:\ORACLE\ORADATAIDB\TEST.DBF' offline;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;alter  database datafile 'G:\ORACLE\ORADATAIDB\TEST.DBF' offline&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;*&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;ERROR at line 1:&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;ORA-01145: offline immediate disallowed unless media recovery  enabled&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;SQL&gt; alter database datafile  'G:\ORACLE\ORADATAIDB\TEST.DBF' offline drop;&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;Database altered.&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;SQL&gt; select count(*) from test_table;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;select count(*) from test_table&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;                    *&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;ERROR at line  1:&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;ORA-00376: file 17 cannot be read at this  time&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;ORA-01110: data file 17:  'G:\ORACLE\ORADATAIDB\TEST.DBF'&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;SQL&gt; alter database datafile  'G:\ORACLE\ORADATAIDB\TEST.DBF' online;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;alter  database datafile 'G:\ORACLE\ORADATAIDB\TEST.DBF' online&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;*&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;ERROR at line 1:&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;ORA-01113: file 17 needs media recovery&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;ORA-01110: data file 17:  'G:\ORACLE\ORADATAIDB\TEST.DBF'&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;SQL&gt; alter database recover datafile  'G:\ORACLE\ORADATAIDB\TEST.DBF';&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;Database altered.&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;SQL&gt; alter database datafile  'G:\ORACLE\ORADATAIDB\TEST.DBF' online;&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;Database altered.&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;SQL&gt; select count(*) from test_table;&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt; COUNT(*)&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;----------&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;    10000&lt;/span&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2967271806809978211-5574377725167528937?l=oracledbs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracledbs.blogspot.com/feeds/5574377725167528937/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2967271806809978211&amp;postID=5574377725167528937' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/5574377725167528937'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/5574377725167528937'/><link rel='alternate' type='text/html' href='http://oracledbs.blogspot.com/2008/01/renaming-datafile.html' title='Renaming A Datafile'/><author><name>Real Time Scenario</name><uri>http://www.blogger.com/profile/11930020132547308855</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2967271806809978211.post-8833927303447216639</id><published>2007-12-30T22:38:00.000-08:00</published><updated>2007-12-30T23:04:56.582-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='happy new year'/><title type='text'>happy new year</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://us.f388.mail.yahoo.com/ya/download/us/ShowLetter?"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 320px;" src="http://us.f388.mail.yahoo.com/ya/download/us/ShowLetter?" alt="" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;img src="http://us.f388.mail.yahoo.com/ya/download/us/ShowLetter?" /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2967271806809978211-8833927303447216639?l=oracledbs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracledbs.blogspot.com/feeds/8833927303447216639/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2967271806809978211&amp;postID=8833927303447216639' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/8833927303447216639'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/8833927303447216639'/><link rel='alternate' type='text/html' href='http://oracledbs.blogspot.com/2007/12/happy-new-year.html' title='happy new year'/><author><name>Real Time Scenario</name><uri>http://www.blogger.com/profile/11930020132547308855</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2967271806809978211.post-7552257746966787806</id><published>2007-12-07T14:55:00.001-08:00</published><updated>2007-12-07T14:58:26.740-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Tablespace Change'/><title type='text'></title><content type='html'>&lt;b&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:180%;"&gt;Tablespace Change&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;  &lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;&lt;b&gt;I created a user as below&lt;/b&gt;&lt;br /&gt;&lt;b&gt;create user paymaster identified by  paymaster&lt;/b&gt;&lt;br /&gt;&lt;b&gt;default tablespace users&lt;/b&gt;&lt;br /&gt;&lt;b&gt;temporary tablespace  temp&lt;/b&gt;&lt;/span&gt;  &lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;&lt;b&gt;this created user paymaster.&lt;/b&gt;&lt;br /&gt;&lt;b&gt;however when i queried&lt;/b&gt;&lt;br /&gt;&lt;b&gt;select owner,tablespace_name from dba_tables&lt;/b&gt;&lt;br /&gt;&lt;b&gt;the output was as  below:-&lt;/b&gt;&lt;/span&gt;  &lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;&lt;b&gt;OWNER TABLESPACE_NAME&lt;/b&gt;&lt;br /&gt;&lt;b&gt;PAYMASTER SYSTEM&lt;/b&gt;&lt;/span&gt;  &lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;&lt;b&gt;the paymaster should be in tablespace 'PAYDATA'&lt;/b&gt;&lt;br /&gt;&lt;b&gt;this tablespace  is already created.&lt;/b&gt;&lt;br /&gt;&lt;b&gt;How do i create user PAYMASTER to use  PAYDATA?&lt;/b&gt;&lt;/span&gt;  &lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;&lt;b&gt;I had earlier dropped user paymtr from the database as the client wants  paymtr to be changed to paymaster.&lt;/b&gt;&lt;br /&gt;&lt;b&gt;I created as above and granted the  roles.&lt;/b&gt;&lt;br /&gt;&lt;b&gt;However when I tried to import from *.dmp file that was  exported from paymaster in another machine(which was in system tablespace) and I  queried from dba_tables to find all tables are in system tablespace.&lt;/b&gt;&lt;br /&gt;&lt;b&gt;How can I retify this?&lt;/b&gt;&lt;/span&gt;  &lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;Change the tablespace from SYSTEM to PAYDATA without dropping the tables.&lt;br /&gt;sql &gt; Alter user PAYMASTER default tablespace PAYDATA&lt;br /&gt;temporary  tablespace TEMP;  &lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;and for each table - move them to PAYDATA tablespace...try to create a script  for the below for all the tables ..  &lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;sql &gt; Alter table tablename default tablespace PAYDATA;  &lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;Also check the indexes ...if they happen to be in SYSTEM tspace do the above  and move them into PAYDATA tablespace or anyother where you wish.  &lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;&lt;b&gt;I have managed to move the tables from system to paydata.  However there  is one table with datatype long which I am unable to move.&lt;/b&gt;&lt;br /&gt;&lt;b&gt;Any  suggestions on how to solve this.&lt;/b&gt;&lt;/span&gt;  &lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;In order to move the table with a LONG col datatype you can generate a table  script manually and import the data into that table.  &lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-family: trebuchet ms;"&gt;If you have problem generating table script use TOAD to generate the table  script and also the INSERT statement script and run the script from sqlplus.You  should be good.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-family: trebuchet ms;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-family: trebuchet ms;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt; &lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2967271806809978211-7552257746966787806?l=oracledbs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracledbs.blogspot.com/feeds/7552257746966787806/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2967271806809978211&amp;postID=7552257746966787806' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/7552257746966787806'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/7552257746966787806'/><link rel='alternate' type='text/html' href='http://oracledbs.blogspot.com/2007/12/tablespace-change-i-created-user-as.html' title=''/><author><name>Real Time Scenario</name><uri>http://www.blogger.com/profile/11930020132547308855</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2967271806809978211.post-6862570604788606849</id><published>2007-12-07T14:53:00.001-08:00</published><updated>2007-12-07T14:54:28.300-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Dynamic Table Names and Moving Table'/><title type='text'></title><content type='html'>&lt;b&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:180%;"&gt;Dynamic Table Names and Moving  Table&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;  &lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;I'm fairly new to PL/SQL and I could use some help.  I'm trying to create a cursor and build the tablename based on an input  parameter. Currently I'm using DBMS.SQL statements, which I find cumbersome to  use. I'd like to find an easier way if possible. Here is an example of what I'd  like to do;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;  &lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;Cursor DYNAMIC is&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;SELECT column1 from I_PARAM||restoftablename&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;in the above example I_PARAM is an input  paramter.&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;  &lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;You can try using "EXECUTE IMMEDIATE" statement create a table  dynamically.....also do get a second opinion.  &lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;*****************&lt;br /&gt;declare&lt;br /&gt;my_table varchar2(400);&lt;br /&gt;begin my_table  := 'create table dynamic_table (my_name varchar2(20))';&lt;br /&gt;EXECUTE IMMEDIATE  my_table;&lt;br /&gt;end;&lt;br /&gt;*****************&lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt; &lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;&lt;b&gt;In Oracle DBS 7.3, how can I move a table from one tablespace to another  without losing permissions, index's...etc for this table?&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;  &lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;Hmmm good question ....i used diff methods but nothing like this in 7x...but  still i'll try....&lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;* First i would take an export of that table (say  mytable.dmp)&lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;* Open mytable.dmp in note pad.&lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;* Edit the tablespace to  the new tablespace name(whichever tablespace u wanna move).&lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;* Save the file&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;* Try to import the dump file(mytable.dmp) into the new user schema u want  to.  &lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;I can't gaurentee that this procedure would work but its worth a try on test  table first.&lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2967271806809978211-6862570604788606849?l=oracledbs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracledbs.blogspot.com/feeds/6862570604788606849/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2967271806809978211&amp;postID=6862570604788606849' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/6862570604788606849'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/6862570604788606849'/><link rel='alternate' type='text/html' href='http://oracledbs.blogspot.com/2007/12/dynamic-table-names-and-moving-table-im.html' title=''/><author><name>Real Time Scenario</name><uri>http://www.blogger.com/profile/11930020132547308855</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2967271806809978211.post-9113849683029536743</id><published>2007-12-07T14:51:00.001-08:00</published><updated>2007-12-07T14:52:56.866-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='User rights'/><category scheme='http://www.blogger.com/atom/ns#' term='Securing Database 9i'/><title type='text'></title><content type='html'>&lt;b&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:180%;"&gt;Securing Database 9i, User  rights&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;  &lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;I have mid-size database that have multiple schemas.  The schema usually accessed by applications. However, there is 5 users who  access the database locally to check some infomations.  In the past they used to  logon as system which cuase some problems! I want to create accounts for them  and give them read-only for all user create schema (no system access). and I  would like to track which user did what.&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;   &lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;grant select any table ....... privilage to the users  this solves the first part.&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;As you're on 9i , you  can use the FGA (Fine Grained Auditing) feature to track the select queries  given by the users.&lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;   &lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;Grant select, resource will gives them read only? will  that enable them to view the data via EM and change or not? I think once they  logged in the EM they will be able to change data?&lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;   &lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;Select is a read only privilage on a table. Why don't you try it out so that  your doubts are cleared.&lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;   &lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;I did test it. the user who have select any table, will not be able to login  to EM, becuase EM have have many data dictionary parameters and instance,  storage and so on.&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;but after&lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt; &lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;grant create session&lt;br /&gt;grant select any dictionry&lt;br /&gt;grant select any  table&lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt; &lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;Then it works fine. So I will create new rule "test" and give it the above  rights then assign it to the users.&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;span style="font-family: trebuchet ms;font-size:130%;" &gt;&lt;br /&gt;&lt;/span&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2967271806809978211-9113849683029536743?l=oracledbs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracledbs.blogspot.com/feeds/9113849683029536743/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2967271806809978211&amp;postID=9113849683029536743' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/9113849683029536743'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/9113849683029536743'/><link rel='alternate' type='text/html' href='http://oracledbs.blogspot.com/2007/12/securing-database-9i-user-rights-i-have.html' title=''/><author><name>Real Time Scenario</name><uri>http://www.blogger.com/profile/11930020132547308855</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2967271806809978211.post-904052638725841164</id><published>2007-12-07T14:45:00.000-08:00</published><updated>2007-12-07T14:51:15.551-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Can we Change a Column Name'/><title type='text'></title><content type='html'>&lt;b&gt;&lt;span style="color: rgb(204, 0, 0);"&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:180%;"&gt;Can we Change a Column  Name&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;  &lt;p style="font-family: trebuchet ms;font-family:trebuchet ms;" &gt;&lt;span style="font-size:130%;"&gt;&lt;b&gt;Suppose I have a table names student having a column named as "&gt;  roll_no". now I have to change its name by " registration_no ". Can we do  this?&lt;/b&gt;&lt;br /&gt;&lt;/span&gt;   &lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;Renaming a column of an Oracle is possible.&lt;br /&gt;ALTER TABLE  ..table_name .. RENAME COLUMN ..old_column_name.. to ..new_column_name..  &lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;Column rename feature is supported by oracle 9.x onwards  &lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;Thus in caes you are using oracle 9.x or later versions use following query &lt;br /&gt;ALTER TABLE tablename RENAME COLUMN oldcolumn TO newcolumn;&lt;br /&gt;In case you  are usinf oracle prior to 9 use following options.&lt;br /&gt;   &lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="color: rgb(153, 0, 0);font-size:130%;" &gt;Other workarounds:&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;1. -- Use a view with correct column names...&lt;br /&gt;    rename t1 to t1_base;&lt;br /&gt;   create view t1 ..column list with new name.. as  select * from t1_base;  &lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;2. -- Recreate the table with correct column names...&lt;br /&gt;   create table t2 ..column list with new name.. as select * from t1;&lt;br /&gt;   drop table t1; &lt;br /&gt;   rename t2 to t1; &lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;font-family:trebuchet ms;" &gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;  &lt;/p&gt;&lt;p style="font-family: trebuchet ms;font-family:trebuchet ms;" &gt;&lt;span style="font-size:130%;"&gt;3. -- Add a column with a new name and drop an old column...&lt;br /&gt; alter  table t1 add ( newcolame datatype );&lt;br /&gt; update t1 set newcolname=oldcolname;&lt;br /&gt; alter table t1 drop column oldcolname;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;   &lt;/p&gt;&lt;p style="font-family: trebuchet ms;font-family:trebuchet ms;" &gt;&lt;span style="font-size:130%;"&gt;You can rename a column in oracle.&lt;br /&gt;try this,&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;ALTER TABLE tablename  RENAME COLUMN oldcolumn TO newcolumn;&lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-family:trebuchet ms;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt; &lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2967271806809978211-904052638725841164?l=oracledbs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracledbs.blogspot.com/feeds/904052638725841164/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2967271806809978211&amp;postID=904052638725841164' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/904052638725841164'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/904052638725841164'/><link rel='alternate' type='text/html' href='http://oracledbs.blogspot.com/2007/12/can-we-change-column-name-rollno.html' title=''/><author><name>Real Time Scenario</name><uri>http://www.blogger.com/profile/11930020132547308855</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2967271806809978211.post-4053751429389154469</id><published>2007-12-07T14:42:00.000-08:00</published><updated>2007-12-07T14:44:42.198-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Shutting Down Oracle On Windows'/><title type='text'></title><content type='html'>&lt;b&gt;&lt;span style="color: rgb(204, 0, 0);"&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:180%;"&gt;Shutting Down Oracle On  Windows&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;  &lt;p style="font-family: trebuchet ms;font-family:trebuchet ms;" &gt;&lt;span style="font-size:130%;"&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;What is the difference between shutting down an Oracle  database (8i and up) on Windows by logging into the instance and issuing the shutdown command vs stoping the Oracle service  (OracleServicedbname)?&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;font-family:trebuchet ms;" &gt;&lt;span style="font-size:130%;"&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;  &lt;/p&gt;&lt;p style="font-family: trebuchet ms;font-family:trebuchet ms;" &gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;I think there's no difference - but you can see many more  informations by logging in with sqlplus/svrmgrl and shutting down the DB with  the shutdown command.&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;Using MMC and shutting down  the service shows only a status bar.&lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;font-family:trebuchet ms;" &gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;&lt;br /&gt;&lt;/span&gt;  &lt;/p&gt;&lt;p style="font-family: trebuchet ms;font-family:trebuchet ms;" &gt;&lt;span style="font-size:130%;"&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;Depends on the version of Oracle and how the instance  is configured in the Windows registry. For 9i (not sure about 8i, don't have an  8i instance anymore), each instance has a key in the registry called  ORA_&lt;sid&gt;_SHUTDOWN_TYPE that determines the type of shutdown to initiate  when the service is stopped (i = immediate for example). The key  ORA_&lt;sid&gt;_SHUTDOWN_TIMEOUT specifies the amount of time to wait (seconds I  think but I never got a clear answer on this) before the instance is  terminated.&lt;/sid&gt;&lt;/sid&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;font-family:trebuchet ms;" &gt;&lt;span style="font-size:130%;"&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;sid&gt;&lt;sid&gt;&lt;br /&gt;&lt;/sid&gt;&lt;/sid&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;  &lt;/p&gt;&lt;p style="font-family: trebuchet ms;font-family:trebuchet ms;" &gt;&lt;span style="font-size:130%;"&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;That being said, in my opinion it is always best to  shutdown the database manually thru SQL*Plus. That way you know what is going  on.&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;  &lt;/p&gt;&lt;p style="font-family: trebuchet ms;font-family:trebuchet ms;" &gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;font-family:trebuchet ms;" &gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;There is a difference.&lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;font-family:trebuchet ms;" &gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;&lt;br /&gt;&lt;/span&gt;  &lt;/p&gt;&lt;p style="font-family: trebuchet ms;font-family:trebuchet ms;" &gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;The service must be running in order to have the database  running.&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;The service can be running without the  database running.&lt;/span&gt;  &lt;/p&gt;&lt;p style="font-family: trebuchet ms;font-family:trebuchet ms;" &gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;font-family:trebuchet ms;" &gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;It's simple to see: start the service, start the database  (if not set to automatic start), then connect as sysdba and do a shutdown. Then  go look at the services - the OracleServiceSID still shows started.&lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;font-family:trebuchet ms;" &gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;&lt;br /&gt;&lt;/span&gt;  &lt;/p&gt;&lt;p style="font-family: trebuchet ms;font-family:trebuchet ms;" &gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;Stop the service, and then start a SQL*Plus session. Try  to connect or start, and you get Oracle not available error.&lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;font-family:trebuchet ms;" &gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;&lt;br /&gt;&lt;/span&gt;  &lt;/p&gt;&lt;p style="font-family: trebuchet ms;font-family:trebuchet ms;" &gt;&lt;span style="font-size:130%;"&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;You can shut down the database either through the sql  prompt or by shutting down the associated oracle service , in both the cases the  database will shutdown its same if your purpose is to shutdown the database a  service is continuously running program which helps other program to run or  execute.&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;font-family:trebuchet ms;" &gt;&lt;span style="font-size:130%;"&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;  &lt;/p&gt;&lt;p style="font-family: trebuchet ms;font-family:trebuchet ms;" &gt;&lt;span style="font-size:130%;"&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;But when you stop the oracle service you close the  door for everything associated with the service so if you stop the service you  cannot start the database unless and until you start the service  again.&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;font-family:trebuchet ms;" &gt;&lt;span style="font-size:130%;"&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;  &lt;/p&gt;&lt;p style="font-family: trebuchet ms;font-family:trebuchet ms;" &gt;&lt;span style="font-size:130%;"&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;If you look at the oracle database from programmers  perspective you can feel oracle database is not one program, its number of  programs running togerther and the oracle service you can think of as the link  between all these programs.&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;font-family:trebuchet ms;" &gt;&lt;span style="font-size:130%;"&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;  &lt;/p&gt;&lt;p style="font-family: trebuchet ms;font-family:trebuchet ms;" &gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;On Windows you have "services" which could be started or  stopped. You can have Oracle DB up/down only if the service is  started.&lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;font-family:trebuchet ms;" &gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;&lt;br /&gt;&lt;/span&gt;  &lt;/p&gt;&lt;p style="font-family: trebuchet ms;font-family:trebuchet ms;" &gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;You can also enable Oracle DB instance to shutdown and  startup with the service shutdown/startup. On *NIX you don't have services and  so such restrictions.&lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;font-family:trebuchet ms;" &gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p  style="font-family:trebuchet ms;"&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2967271806809978211-4053751429389154469?l=oracledbs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracledbs.blogspot.com/feeds/4053751429389154469/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2967271806809978211&amp;postID=4053751429389154469' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/4053751429389154469'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/4053751429389154469'/><link rel='alternate' type='text/html' href='http://oracledbs.blogspot.com/2007/12/shutting-down-oracle-on-windows-what-is.html' title=''/><author><name>Real Time Scenario</name><uri>http://www.blogger.com/profile/11930020132547308855</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2967271806809978211.post-9096178285175492468</id><published>2007-12-07T14:40:00.000-08:00</published><updated>2007-12-07T14:41:58.624-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Tuning a Wait Session'/><title type='text'></title><content type='html'>&lt;b&gt;&lt;span style="color: rgb(204, 0, 0);"&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:180%;"&gt;&lt;br /&gt;Tuning a Wait  Session&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;  &lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;When I was about to bring down the server in an  immediate mode for the start of the weekend maintenace window, I saw a user  session is still active where he was trying to run a query. This query, in the  past, took a minute or so and now its more than half hour. All I could do is  kill it.&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;The thing I am wondering about is, if time permits,  the approach towards tuning it. How do I find out which object is he accessing,  is there a wait for any latches or is it undergoing any full table scans or is  it waiting for any resource to be freed and etc..&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;  &lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;-----&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;The first thing  you should do is select * from v$session_wait where sid = [his session ID]. We  can go from there. Run that query multiple times a few seconds apart.&lt;/span&gt;  &lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;-----&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;****************&lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;To find out what  sql the problem session(s) are executing, run the following query:&lt;/span&gt;  &lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;select s.sid, event, wait_time, w.seq#, q.sql_text&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;from v$session_wait w, v$session s, v$process p,  v$sqlarea q&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;where s.paddr=p.addr and&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;s.sid=&amp;amp;p and&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;s.sql_address=q.address;&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;****************&lt;/span&gt;  &lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;I suggest you drop v$process from that query because  you're not using anything in it. And suggest you change v$sqlarea to v$sql  because the latter is much less expensive.&lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;&lt;br /&gt;&lt;/span&gt;  &lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;To be more accurate, v$sql (or v$sqlarea) contains the  SQL the session either is running or last ran, depending on the info in  v$session_wait.&lt;/span&gt; &lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2967271806809978211-9096178285175492468?l=oracledbs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracledbs.blogspot.com/feeds/9096178285175492468/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2967271806809978211&amp;postID=9096178285175492468' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/9096178285175492468'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/9096178285175492468'/><link rel='alternate' type='text/html' href='http://oracledbs.blogspot.com/2007/12/tuning-wait-session-when-i-was-about-to.html' title=''/><author><name>Real Time Scenario</name><uri>http://www.blogger.com/profile/11930020132547308855</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2967271806809978211.post-2993459442339073083</id><published>2007-12-07T14:38:00.000-08:00</published><updated>2007-12-07T14:40:24.439-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Update B with the Help of A'/><title type='text'></title><content type='html'>&lt;b&gt;&lt;span style="color: rgb(204, 0, 0);"&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:180%;"&gt;Update B with the Help of  A&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;  &lt;p&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;b&gt;I am in great problem since last 3 days by the following problem.&lt;/b&gt;&lt;br /&gt;&lt;b&gt; &lt;/b&gt;&lt;br /&gt;&lt;b&gt;I have 2 tables as A and B both having 2 fields as name and  roll. I have to update the B table with respect to table A.&lt;/b&gt;  &lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;b&gt;Can we do this  with the help of query.&lt;/b&gt;&lt;br /&gt;&lt;b&gt;I have written a code  for this and giving error and system goes to infinite loop.&lt;/b&gt;  &lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;b&gt;The code is following:&lt;/b&gt;&lt;br /&gt;&lt;b&gt; &lt;/b&gt;&lt;br /&gt;&lt;b&gt;Declare&lt;/b&gt;&lt;br /&gt;&lt;b&gt;cursor  c1 is select * from A where roll IN ( select roll from B);&lt;/b&gt;&lt;br /&gt;&lt;b&gt;rec_set  emp1%rowtype;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;begin&lt;/b&gt;&lt;br /&gt;&lt;b&gt;open c1;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;fetch c1 into  rec_set;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;loop&lt;/b&gt;&lt;br /&gt;&lt;b&gt;update B set B.name=rec.set.name where  B.roll=rec_set.roll;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;end loop;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;close c1;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;end;&lt;/b&gt;&lt;br /&gt;&lt;b&gt; &lt;/b&gt;&lt;br /&gt;&lt;b&gt;When I complied this block, it then goes to  infinite and then I need to stop its services to again login the system.&lt;/b&gt;  &lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;Looks like in the line  &lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;update B set B.name=rec.set.name where B.roll=rec_set.roll;  &lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;the underlined part should be rec_set&lt;br /&gt;&lt;br /&gt;I think this could be done  using a single query also&lt;br /&gt;&lt;br /&gt;update B  &lt;/p&gt;&lt;p&gt;&lt;span style="font-family: trebuchet ms;"&gt;set B.name = (select name from A T1where T1.roll = B.roll)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: trebuchet ms;"&gt;be careful the  above query will be valid only if the embedded query returns just one row.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;span style="font-family: trebuchet ms;"&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: trebuchet ms;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2967271806809978211-2993459442339073083?l=oracledbs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracledbs.blogspot.com/feeds/2993459442339073083/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2967271806809978211&amp;postID=2993459442339073083' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/2993459442339073083'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/2993459442339073083'/><link rel='alternate' type='text/html' href='http://oracledbs.blogspot.com/2007/12/update-b-with-help-of-i-am-in-great.html' title=''/><author><name>Real Time Scenario</name><uri>http://www.blogger.com/profile/11930020132547308855</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2967271806809978211.post-2111946385328521517</id><published>2007-12-07T14:34:00.000-08:00</published><updated>2007-12-07T14:37:36.781-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Changing Prompt in SQL Plus'/><title type='text'></title><content type='html'>&lt;b&gt;&lt;span style="color: rgb(204, 0, 0);"&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:180%;"&gt;Changing Prompt in SQL  Plus&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;  &lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;I have more then one Oracle 8 database servers. I need to  have SQL promp to be my connect string. Username whenever I login in SQL Plus.  Connect String is the same as Server Name.&lt;/span&gt;  &lt;/p&gt;&lt;p style="font-family: trebuchet ms; color: rgb(204, 0, 0);"&gt;&lt;span style="color: rgb(0, 0, 0);font-size:180%;" &gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms; color: rgb(204, 0, 0);"&gt;&lt;span style="color: rgb(0, 0, 0);font-size:180%;" &gt;Example:&lt;/span&gt;  &lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;Server 1 = aaaaa&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;Server 2  = bbbbb&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;Username = Naaa&lt;/span&gt;  &lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;Prompt should be&lt;/span&gt;  &lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;aaaaa.Naaa or bbbbb.Naaa &lt;/span&gt;  &lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;I use  the following sql script to change my prompt. Modify it according to your  requirements.&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;Copy and paste the below script  (between .............) into a file named login.sql.&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;Copy this login.sql file in the working directory of your sqlplus  (like c:\oracle\ora81\bin).&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;Oracle looks for a  file named login.sql in its working directory. If it finds one then it executes  it.&lt;/span&gt;  &lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;..................&lt;/span&gt;  &lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;set lines 1000&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;set pages  50&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;set serverout on size 500000&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;set head off&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;set pages 0&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;set termout off&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;alter  session set nls_date_format = 'DD-MON-YYYY HH24:MI:SS'&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;/&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;spool z1.sql&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;select 'set sqlprompt '''||lower(global_name)||':'||user||''''  from sys.global_name&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;/&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;spool off&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;@z1&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;set head on&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;set pages 60&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;set termout on&lt;/span&gt;  &lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;...................&lt;/span&gt;  &lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;I  take a slightly different approach. I use the "new_value" clause of the column  statement.&lt;/span&gt;  &lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;Here is the script:&lt;/span&gt;  &lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;-- setPrompt.sql&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;--  -------------&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;set term off&lt;/span&gt;  &lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;column prompt_col new_value prompt_var&lt;/span&gt;  &lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;define prompt_var = "not connected&gt; "&lt;/span&gt;  &lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;set prompt off&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;select  lower(user) || '@' || ' (' || global_name || ')' || chr(10) || ' &gt; '  prompt_col&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;from global_name&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;/&lt;/span&gt;  &lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;set sqlprompt "&amp;amp;prompt_var"&lt;/span&gt;  &lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;set term on&lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;&lt;br /&gt;&lt;/span&gt; &lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2967271806809978211-2111946385328521517?l=oracledbs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracledbs.blogspot.com/feeds/2111946385328521517/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2967271806809978211&amp;postID=2111946385328521517' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/2111946385328521517'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/2111946385328521517'/><link rel='alternate' type='text/html' href='http://oracledbs.blogspot.com/2007/12/changing-prompt-in-sql-plus-i-have-more.html' title=''/><author><name>Real Time Scenario</name><uri>http://www.blogger.com/profile/11930020132547308855</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2967271806809978211.post-2505481595478625217</id><published>2007-12-07T13:16:00.000-08:00</published><updated>2007-12-07T13:31:38.360-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Droping Logfile Group Failed'/><title type='text'></title><content type='html'>&lt;span style="color: rgb(153, 0, 0);font-size:180%;" &gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-weight: bold; color: rgb(153, 0, 0);font-size:180%;" &gt;Droping Logfile Group Failed&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-family: trebuchet ms;"&gt;How to drop a log file group that is being the current logfile group? &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: trebuchet ms;"&gt;I have 4 groups. In that I want to drop one group and that group is the active one. &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: trebuchet ms;"&gt;If I drop that group it is telling that it is the current group. &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: trebuchet ms;"&gt;If I try to switch logfile it is telling that database is not open. &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: trebuchet ms;"&gt;-----&gt; &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: trebuchet ms;"&gt;Have you use the SYS user to start the database ? &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: trebuchet ms;"&gt;SQL&gt; conn sys/&lt;/span&gt;&lt;/span&gt;&lt;password style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt; as sysdba&lt;br /&gt;connected to an idle instance&lt;br /&gt;SQL&gt; startup&lt;br /&gt;&lt;br /&gt;-----&gt;&lt;br /&gt;In mount stage I want to drop it.&lt;br /&gt;&lt;br /&gt;-----&gt;&lt;br /&gt;In mount stage you can drop non-current log group but cannot drop or switch current log group.&lt;br /&gt;&lt;br /&gt;-----&gt;&lt;br /&gt;&lt;br /&gt;1. You must have at- least two online groups.&lt;br /&gt;&lt;br /&gt;2. You can not drop a active online active redo log group.&lt;br /&gt;&lt;br /&gt;3. If it active switch it by alter system switch logfile before dropping.&lt;br /&gt;&lt;br /&gt;3. make sure that online redo log group is archived ( if archiving is enabled).&lt;br /&gt;&lt;br /&gt;Syntax :- Alter database drop logfile group &lt;/span&gt;&lt;group no=""&gt;&lt;span style="font-size:130%;"&gt;.&lt;br /&gt;&lt;br /&gt;-----&gt;&lt;br /&gt;&lt;br /&gt;Open the database&lt;br /&gt;switch logfile.&lt;br /&gt;drop the logfile&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Why do you want to drop the logfile only on mount stage??&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;-----&gt;&lt;br /&gt;&lt;br /&gt;There was some problem with the logfile while opening the database.   So to rectify that I need to drop that group.&lt;br /&gt;&lt;br /&gt;Database is not starting.. If it get started then I would have used switch log file command then I would have droped it.&lt;br /&gt;Since it is not starting I am forced to drop it in mount stage.&lt;br /&gt;&lt;br /&gt;Since the log file is the current log then in mount stage switch log file is not working.&lt;br /&gt;So what I did I recreated control file.  Now it is working&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;-----&gt;&lt;br /&gt;&lt;br /&gt;Well if the problem has been solved, No issues.&lt;br /&gt;But the appropriate solution would have been:&lt;br /&gt;&lt;br /&gt;Alter database clear unarchived logfile group &lt;&gt;;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;-----&gt;&lt;br /&gt;My database is in no archivelog mode.. will it work....&lt;br /&gt;&lt;br /&gt;Moreover suppose if it is in archivelog mode then&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;If we clare the logfile group will it clear the data or will it move the data to the logfiles... and what effect will be there if the database is in archivelog mode? Like dataloss?&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;-----&gt;&lt;br /&gt;This statement is to be used only when the current logfile has became corrupt and cannot be dropped.It will simply clear the contents and will not copy them any other log group&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;ALTER DATABASE CLEAR LOGFILE GROUP &lt;/span&gt;&lt;group_number&gt;&lt;span style="font-size:130%;"&gt;;&lt;br /&gt;Use this for noarchivelog mode&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;ALTER DATABASE CLEAR UNARCHIVED LOGFILE GROUP &lt;/span&gt;&lt;group_number&gt;&lt;span style="font-size:130%;"&gt;;&lt;br /&gt;&lt;br /&gt;Use this verison of clearing a log file if the corrupt log file has not been archived&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;-----&gt;&lt;br /&gt;I have a question how does creating a new control file , solves the problem as the new control file will be pointing to the current logfile which has the problem&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;-----&gt;&lt;br /&gt;In the new control which I created in the trace file I edited and droped the logfile which is giving problem and then assigend the new control file to the database.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;/group_number&gt;&lt;/group_number&gt;&lt;/group&gt;&lt;/password&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2967271806809978211-2505481595478625217?l=oracledbs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracledbs.blogspot.com/feeds/2505481595478625217/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2967271806809978211&amp;postID=2505481595478625217' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/2505481595478625217'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/2505481595478625217'/><link rel='alternate' type='text/html' href='http://oracledbs.blogspot.com/2007/12/droping-logfile-group-failed-how-to.html' title=''/><author><name>Real Time Scenario</name><uri>http://www.blogger.com/profile/11930020132547308855</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2967271806809978211.post-3333695226365873256</id><published>2007-12-07T11:47:00.000-08:00</published><updated>2007-12-07T12:45:11.413-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Scan n Skip Scan In Oracle'/><title type='text'></title><content type='html'>&lt;span style="font-size:180%;"&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color: rgb(204, 0, 0);"&gt;Advantage Between Range Scan &amp;amp; Skip  Scan In Oracle&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;  &lt;p&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;font-family:trebuchet ms;" &gt;&lt;span style="font-size:130%;"&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;Can someone explain me how the range scan is better  than Skip Scan in Oracle 9i.&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;Is it  advantage of tuning queries to take RANGE SCAN access path than SKIP SCAN  path?&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;  &lt;/p&gt;&lt;p style="font-family: trebuchet ms;font-family:trebuchet ms;" &gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;In index range scans,&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;&lt;&lt;/span&gt;/quotedoc&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;&gt;&lt;/span&gt;  &lt;/p&gt;&lt;p style="font-family: trebuchet ms;font-family:trebuchet ms;" &gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;Multiple rows with identical values are sorted in  ascending order by rowid.&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;&lt;  /quotedoc&gt;&lt;/span&gt;  &lt;/p&gt;&lt;p style="font-family: trebuchet ms;font-family:trebuchet ms;" &gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;in Skip scan&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;font-family:trebuchet ms;" &gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt; &lt;/span&gt;quotedoc&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;&gt;&lt;/span&gt;  &lt;/p&gt;&lt;p style="font-family: trebuchet ms;font-family:trebuchet ms;" &gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;Skip scanning lets a composite index be split logically  into smaller subindexes. In skip scanning, the initial column of the composite  index is not specified in the query. In other words, it is skipped.&lt;/span&gt;  &lt;/p&gt;&lt;p style="font-family: trebuchet ms;font-family:trebuchet ms;" &gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;The number of logical subindexes is determined by the  number of distinct values in the initial column. Skip scanning is advantageous  if there are few distinct values in the leading column of the composite index  and many distinct values in the nonleading key of the index.&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;font-family:trebuchet ms;" &gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;&lt; /quotedoc&gt;&lt;/span&gt;  &lt;/p&gt;&lt;p style="font-family: trebuchet ms;font-family:trebuchet ms;" &gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;My understanding is,&lt;/span&gt;&lt;span style="font-size:130%;"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;Skip  scanning is good only if the cardinality of the leading columns are low ( very  few distinct records).&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;if the cardinality of the  rest columns are too low, eventually the CBO will ignore the indexes.&lt;/span&gt;  &lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2967271806809978211-3333695226365873256?l=oracledbs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracledbs.blogspot.com/feeds/3333695226365873256/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2967271806809978211&amp;postID=3333695226365873256' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/3333695226365873256'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/3333695226365873256'/><link rel='alternate' type='text/html' href='http://oracledbs.blogspot.com/2007/12/advantage-between-range-scan-skip-scan.html' title=''/><author><name>Real Time Scenario</name><uri>http://www.blogger.com/profile/11930020132547308855</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2967271806809978211.post-1505113630848592028</id><published>2007-12-07T11:15:00.000-08:00</published><updated>2007-12-07T11:45:27.166-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='How Can I Copy Data in Another System'/><title type='text'></title><content type='html'>&lt;b&gt;&lt;span style="color:#cc0000;"&gt;&lt;span style="font-size:+2;"&gt;How Can I Copy Data in Another  System&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;  &lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;&lt;b&gt;I am using oracle 9i.&lt;/b&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;&lt;b&gt;Now I want to copy its whole data like  tables, cursors, function, procedure and trigger to an another system which has  no link with my first system.&lt;/b&gt;&lt;/span&gt;  &lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;Oracle export (EXP) and import (IMP) utilities are used to perform logical  database backup and recovery. export / import are logical backup system in  oracle.  &lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;Just type exp(in case of export) or imp (in case of import) at prompt, you  will get online help from oracle and supply parameters, it will serve your  purpose.  &lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;Otherwise, the command is  &lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;login as sys user and give command...  &lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;exp file=..filename.dmp.. full=y statistics = none   (will export all  schema backups)  &lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;for example,  &lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;exp scott/tiger file=emp.dmp log=emp.log tables=emp rows=yes indexes=no &lt;br /&gt;(table level export)&lt;br /&gt;         exp scott/tiger file=emp.dmp  tables=(emp,dept) (exporting 2 tables)  &lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;Similarly import command will be like....  &lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;         imp scott/tiger file=emp.dmp full=yes&lt;br /&gt;         imp scott/tiger  file=emp.dmp fromuser=scott touser=scott&lt;br /&gt;tables=dept&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2967271806809978211-1505113630848592028?l=oracledbs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracledbs.blogspot.com/feeds/1505113630848592028/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2967271806809978211&amp;postID=1505113630848592028' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/1505113630848592028'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/1505113630848592028'/><link rel='alternate' type='text/html' href='http://oracledbs.blogspot.com/2007/12/how-can-i-copy-data-in-another-system-i.html' title=''/><author><name>Real Time Scenario</name><uri>http://www.blogger.com/profile/11930020132547308855</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2967271806809978211.post-174395505633578177</id><published>2007-12-07T11:01:00.000-08:00</published><updated>2007-12-07T11:12:44.618-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Is IMPORT n EXPORT is platform dependent'/><title type='text'></title><content type='html'>&lt;span style="font-size:180%;"&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;&lt;br /&gt;Is IMPORT &amp;amp; EXPORT is platform  dependent&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;  &lt;p&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;Please help me to find the soultion for this,,,,&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p  style="font-family:trebuchet ms;"&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt; &lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;I'll explain u my  problem....&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt; &lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;1. I  have a Unix server Running Oracle 7.2&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;2. I have a  user called 'Namankan' on Oracle DB&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;3. I have to  shift the entire tables of user 'Namankan' from this System to a new server  running Windows XP (or NT) with Oracle 8 (Not 8i)&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt; &lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;If you are going to suggest me  that I spool the entire data into text files and import them by running  SQL*Loader in the new system, Pls dont suggest.......coz&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;i) Data is too large, ii) Table level validations in database will  not allow the data to go in.&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;I have tried making  a .dmp file using exp command on Unix Machine with default parameters, and have  exported the entire data into a file called Intecons.dmp which is 175 MB, zipped  into 28MB&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt; &lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;Then I  have taken this file onto Windows system with Oracle 8 and tried to import it  through Imp80 command&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt; &lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;It says&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;* Invalid Header  Information, OS different (some such 2-3 lines)&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt; &lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;As suggested by someone in a  yahoo chat room, I Have tried to change the header information in .dmp file  using a hex editor, I matched it to same as it was in a sample .dmp I made using  exp80 command on my windows machine.......... Sometimes, it asks 2-3 questions  and after replies starts dumping junk......... sometimes it hangs the  system&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt; &lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;I also  came across to a data extraction program NXTract, however, its similar to  spooling of files, even if it extracts data from .dmp file, so it is useless for  me&lt;/span&gt;  &lt;/p&gt;&lt;p  style="font-family:trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;&lt;b&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;  &lt;/p&gt;&lt;p  style="font-family:trebuchet ms;"&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;IMP/EXP IS NOT PLATFORM DEPENDANT!!!!!!!!&lt;/span&gt;  &lt;/p&gt;&lt;p  style="font-family:trebuchet ms;"&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;Gawd Hex editor hacking on dmp binary files.... thatz  weird!!!&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;The guy who gave you that advice is  either brilliant&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;or&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;....let me leave this here&lt;/span&gt;  &lt;/p&gt;&lt;p  style="font-family:trebuchet ms;"&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);font-size:130%;" &gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p  style="font-family:trebuchet ms;"&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);font-size:130%;" &gt;Firstly:&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt; &lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p  style="font-family:trebuchet ms;"&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;With the Oracle  EXPORT and IMPORT utilities you can transfer data objects  between Oracle  databases, even if they reside on platforms with different  hardware and  software configurations.&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;ie:  Dump files also  aren't OS-specific; as a result, you can use Export/Import to transfer data  between databases on different platforms.&lt;/span&gt;  &lt;/p&gt;&lt;p  style="font-family:trebuchet ms;"&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);font-size:130%;" &gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p  style="font-family:trebuchet ms;"&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);font-size:130%;" &gt;Secondly:&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt; &lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p  style="font-family:trebuchet ms;"&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;Exporting data  from a lower version of oracle into a higher version===no problem&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;The vice versa ==== got to do it  tactically!!&lt;/span&gt;  &lt;/p&gt;&lt;p  style="font-family:trebuchet ms;"&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p  style="font-family:trebuchet ms;"&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;IN your case Puneeth:&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p  style="font-family:trebuchet ms;"&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;From  7.3.3 to 8 =&gt; Use the EXPORT 7.3.3 to export the data from the 7.3.3 database  and IMPORT 8 to import the data into the 8 database. This should work just fine  without any dependancy on the OS.&lt;/span&gt;  &lt;/p&gt;&lt;p  style="font-family:trebuchet ms;"&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;The PROBLEM of yours could be simple as this:&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;Did you use ftp to transfer the dmp file from the unix  system in to ur target machine?&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;IF SO: did you  type&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p  style="font-family:trebuchet ms;"&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;ftp..bin&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p  style="font-family:trebuchet ms;"&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;before you did the transfer?&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p  style="font-family:trebuchet ms;"&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;When  transferring the export dump file over a network, the file has to be transmitted  in binary mode.&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p  style="font-family:trebuchet ms;"&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;Transmitting export files in  character mode (&lt;a href="http://oracledbs.blogspot.com/"&gt;ASCII&lt;/a&gt;) causes errors when the file is imported.&lt;/span&gt;  &lt;/p&gt;&lt;p  style="font-family:trebuchet ms;"&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;If the problem is still not solved post the errors that  are being logged so that we could actually understand the problem come up with  some clear cut answer!!!&lt;/span&gt;  &lt;/p&gt;&lt;p  style="font-family:trebuchet ms;"&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;I see that you have actually posted a similar posting  somewhere where you have suggested to pay the person who helps you get through  this.... so is that offer still valid here :+)&lt;/span&gt;   &lt;/p&gt;&lt;p  style="font-family:trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p  style="font-family:trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;&lt;b&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;  &lt;/p&gt;&lt;p  style="font-family:trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;As per oracle corp: &lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p  style="font-family:trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;When creating an export dump file for an import into  a higher release database (e.g.: from Oracle8i to Oracle9i), use a version of  the EXPORT utility that is equal to the version of the source database (= lowest  version = Oracle8i in this case).&lt;br /&gt;The export FAILS if you use a HIGHER  release export version.&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p  style="font-family:trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;For example, if you use the export 9.0.1 utility the  export data from an 8.1.7 database, you will get&lt;span style="font-weight: bold; font-style: italic; color: rgb(204, 0, 0);"&gt; the errors: &lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p  style="font-family:trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;         EXP-56  Oracle error 942 encountered&lt;br /&gt;        ORA-942 table or view does not exist&lt;br /&gt;        EXP-0 Export terminated unsuccessfully&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p  style="font-family:trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;Solution: use the lowest  release export utility (8.1.7 in this case).  &lt;/span&gt;&lt;/p&gt;&lt;p  style="font-family:trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;Hence I dnt think you can use oracle8 exp on the oracle7.3 database and get  things right....!!  &lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-family:trebuchet ms;"&gt;And i totally agree HEX editor on dmp files==bad idea.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:trebuchet ms;"&gt;&lt;br /&gt;&lt;/span&gt; &lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2967271806809978211-174395505633578177?l=oracledbs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracledbs.blogspot.com/feeds/174395505633578177/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2967271806809978211&amp;postID=174395505633578177' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/174395505633578177'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/174395505633578177'/><link rel='alternate' type='text/html' href='http://oracledbs.blogspot.com/2007/12/is-import-export-is-platform-dependent.html' title=''/><author><name>Real Time Scenario</name><uri>http://www.blogger.com/profile/11930020132547308855</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2967271806809978211.post-5348918052973259787</id><published>2007-12-07T10:47:00.000-08:00</published><updated>2007-12-07T10:59:47.520-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Error in PL/SQL block of trigger'/><title type='text'></title><content type='html'>&lt;b&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:180%;"&gt;Error in PL/SQL block of  trigger&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;  &lt;p&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;span style="color:#ff0000;"&gt;&lt;span style="font-size:+2;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;  &lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;&lt;b&gt;I have written a trigger whose PL/SQL block contains a simple select  statment among many other statements.&lt;/b&gt;&lt;br /&gt;&lt;b&gt;Now I find that, if the select  statement returns no rows the trigger does not continue its operation further  and aborts there itself. And if the select statement returns some rows, then it  works fine.&lt;/b&gt;&lt;/span&gt;  &lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;&lt;b&gt;I tried to execute a simplified PL/SQL block of the trigger in SQL*Plus  and following were the results:&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;  &lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;&lt;b&gt;************************&lt;/b&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;&lt;b&gt;declare&lt;/b&gt;&lt;br /&gt;&lt;b&gt;tempdate date;&lt;/b&gt; &lt;br /&gt;&lt;b&gt;begin&lt;/b&gt;&lt;br /&gt;&lt;b&gt;select trdt into tempdate from inv_trans;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;if  sql%notfound then&lt;/b&gt;&lt;br /&gt;&lt;b&gt;null;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;end if;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;end;&lt;/b&gt; &lt;br /&gt;&lt;b&gt;/&lt;/b&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;&lt;b&gt;************************&lt;/b&gt;&lt;/span&gt;  &lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;&lt;b&gt;When no data is present in inv_trans table, the result was:&lt;/b&gt; &lt;br /&gt;&lt;b&gt;************************&lt;/b&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;&lt;b&gt;declare&lt;/b&gt;&lt;br /&gt;&lt;b&gt;*&lt;/b&gt;&lt;br /&gt;&lt;b&gt;ERROR  at line 1:&lt;/b&gt;&lt;br /&gt;&lt;b&gt;ORA-01403: no data found&lt;/b&gt;&lt;br /&gt;&lt;b&gt;ORA-06512: at line  4&lt;/b&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;&lt;b&gt;************************&lt;/b&gt;&lt;/span&gt;  &lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;&lt;b&gt;And when the table inv_trans had data, the result was:&lt;/b&gt; &lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;&lt;b&gt;************************&lt;/b&gt;&lt;br /&gt;&lt;b&gt;PL/SQL procedure successfully  completed.&lt;/b&gt;&lt;br /&gt;&lt;b&gt;************************&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;  &lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;&lt;b&gt;Why is the piece of code flashing an error when I have already given a  treatment if no data is found.&lt;/b&gt;&lt;br /&gt;&lt;b&gt;Why is it taking "No Data in table" as  an abnormal condition and not normal?&lt;/b&gt;&lt;/span&gt;  &lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;-------------------------&lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;  &lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;color:#000000;"&gt;Your problem is in the fact that you haven't given a  treatment if no data was found, as you said you've been doing'.&lt;/span&gt;  &lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;color:#000000;"&gt;sql%notfound was never reached in case where no record  was returned.&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:130%;color:#000000;"&gt;The exception was raised in the  select into statement.&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:130%;color:#000000;"&gt;That's the default Oracle  behaviour.&lt;/span&gt;  &lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;color:#000000;"&gt;select into statement always raise ORA-01403 error&lt;/span&gt;&lt;span style="font-size:130%;"&gt; &lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:130%;color:#000000;"&gt;if no record was returned and no value set into  variable.&lt;/span&gt;  &lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;color:#000000;"&gt;You'll have to handle the exception.&lt;/span&gt;  &lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;color:#000000;"&gt;Here is the code that will work the same logic, without  any &lt;span style="font-weight: bold;"&gt;problem:&lt;/span&gt;&lt;/span&gt;  &lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;color:#000000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;color:#000000;"&gt;[color=red]declare&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:130%;color:#000000;"&gt;tempdate date;&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:130%;color:#000000;"&gt;begin&lt;/span&gt;&lt;span style="font-size:130%;"&gt; &lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:130%;color:#000000;"&gt;select trdt into tempdate from inv_trans;&lt;/span&gt;&lt;span style="font-size:130%;"&gt; &lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:130%;color:#000000;"&gt;exception&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:130%;color:#000000;"&gt;when  no_data_found then&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:130%;color:#000000;"&gt;null;&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:130%;color:#000000;"&gt;end;&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:130%;color:#000000;"&gt;/ [/color]&lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;/span&gt; &lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2967271806809978211-5348918052973259787?l=oracledbs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracledbs.blogspot.com/feeds/5348918052973259787/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2967271806809978211&amp;postID=5348918052973259787' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/5348918052973259787'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/5348918052973259787'/><link rel='alternate' type='text/html' href='http://oracledbs.blogspot.com/2007/12/error-in-plsql-block-of-trigger-i-have.html' title=''/><author><name>Real Time Scenario</name><uri>http://www.blogger.com/profile/11930020132547308855</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2967271806809978211.post-1398596683595949025</id><published>2007-12-07T10:22:00.001-08:00</published><updated>2007-12-07T10:47:31.699-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Using Trigger And Procedure Together'/><title type='text'></title><content type='html'>&lt;b&gt;&lt;span style="color: rgb(204, 0, 0);"&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:180%;"&gt;Using Trigger And Procedure  Together&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="color:#000000;"&gt;&lt;span style="font-weight: bold;"&gt;Table Name:&lt;/span&gt; INSTRUCTOR&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="color:#000000;"&gt;INSTRUCTOR_ID INSTRUCTOR_NAME SALARY COMMISSION MENTOR_ID  DATE_HIRE&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="color:#000000;"&gt;------------- --------------- ---------  ---------- --------- ---------&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="color:#000000;"&gt;700 WAYNE 4500 300  16-MAY-81&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;628 MONROE 3000 700 16-JUN-84&lt;/span&gt; &lt;br /&gt;&lt;span style="color:#000000;"&gt;790 NEWMAN 3100 300 700 16-DEC-82&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;795 BOGART 3200 700 16-DEC-83&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;515  SHELLEY 3500 200 700 20-JAN-91&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;222 CAINE 5500 350  02-NOV-76&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;978 STEEL 5000 250 222 16-JAN-80&lt;/span&gt; &lt;br /&gt;&lt;span style="color:#000000;"&gt;560 LAUREL 5200 200 978 16-DEC-83&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;835 SPARKS 4000 200 978 16-DEC-84&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;243 TUCKER 2000 835 18-DEC-90&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;263  JOHNSON 4000 835 18-JUL-92&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;453 LODGE 2500 100 835  14-SEP-88&lt;/span&gt;  &lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="color:#000000;"&gt;&lt;span style="font-weight: bold; font-style: italic; color: rgb(153, 51, 0);"&gt;Table Name:&lt;/span&gt; AUTH&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;INSTRUCTOR_ID COURSE_ID AUTH_DATE&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="color:#000000;"&gt;------------- --------- ---------&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="color:#000000;"&gt;222 315 14-MAR-90&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;222 415  13-JAN-92&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;978 815 14-MAR-89&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;700 315 14-FEB-91&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;835 515  12-MAR-92&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;515 915 22-APR-91&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;263 215 14-JUN-92&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;263 315  14-FEB-92&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;453 715 14-AUG-93&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;790 315 14-AUG-91&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;560 915  14-AUG-91&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;453 615 14-JUL-93&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;628 315 13-JUL-91&lt;/span&gt;  &lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="color: rgb(204, 102, 0);font-size:130%;color:#000000;"  &gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="color: rgb(204, 102, 0);font-size:130%;color:#000000;"  &gt;My Question requirement is:&lt;/span&gt;&lt;span style="color: rgb(204, 102, 0);font-size:130%;" &gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;1) From the INSTRUCTOR table, if the salary of that instructor  &gt;= 3750, then he/she can insert new record on the AUTH table, BUT if salary  &lt;&gt;  &lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="color:#000000;"&gt;SO, I SOLVE this question using the method below, and can  some one help me to check any logic error on it.&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="color:#000000;"&gt;cause even i insert a new record where the instructor salary  already &lt;&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="color:#000000;"&gt; *********&lt;/span&gt;&lt;span style="color:#000000;"&gt;******************************************************&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="color:#000000;"&gt;INSERT INTO INSTRUCTOR(INSTRUCTOR_ID,&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;INSTRUCTOR_NAME,&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;SALARY,&lt;/span&gt; &lt;br /&gt;&lt;span style="color:#000000;"&gt;COMMISSION,&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;MENTOR_ID,&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;DATE_HIRED)&lt;/span&gt; &lt;br /&gt;&lt;span style="color:#000000;"&gt;VALUES (100, 'JOSH', 2000, 500, 700,  '11-AUG-05');&lt;/span&gt;  &lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="color:#000000;"&gt;INSERT INTO AUTH(INSTRUCTOR_ID,&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;COURSE_ID,&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;AUTH_DATE)&lt;/span&gt; &lt;br /&gt;&lt;span style="color:#000000;"&gt;VALUES(100, 515, '11-AUG-05');&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="color:#000000;"&gt;******************************************************&lt;/span&gt; &lt;br /&gt;&lt;span style="color:#000000;"&gt;=============================================================================&lt;/span&gt; &lt;br /&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="color:#000000;"&gt;CREATE OR REPLACE TRIGGER CHECK_SALARY_TR&lt;/span&gt; &lt;br /&gt;&lt;span style="color:#000000;"&gt;BEFORE INSERT&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;ON  AUTH&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;DECLARE&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;SALARY INSTRUCTOR.SALARY%TYPE;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;BEGIN&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;IF (SALARY lessthan=  3750)THEN&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;RAISE_APPLICATION_ERROR(-20101,'THANKS,  YOU HAVE AN AUTHORIZATION TO OFFER COURSES');&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;ELSIF (SALARY lessthan 3750) THEN&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;RAISE_APPLICATION_ERROR(-20102,'SORRY, YOU DO NOT HAVE  AUTHORIZATION TO OFFER COURSES');&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;END IF;&lt;/span&gt; &lt;br /&gt;&lt;span style="color:#000000;"&gt;END;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="color:#000000;"&gt;=============================================================================&lt;/span&gt; &lt;br /&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="color:#000000;"&gt;CREATE OR REPLACE PROCEDURE  INSERT_AUTH_PROC(P_INSTRUCTOR_ID AUTH.INSTRUCTOR_ID%TYPE,&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;P_COURSE_ID AUTH.COURSE_ID%TYPE,&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;P_AUTH_DATE AUTH.AUTH_DATE%TYPE ) IS&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;BEGIN&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;INSERT INTO  AUTH(INSTRUCTOR_ID, COURSE_ID, AUTH_DATE)&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;VALUES  (P_INSTRUCTOR_ID, P_COURSE_ID, P_AUTH_DATE);&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;END  INSERT_AUTH_PROC;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="color:#000000;"&gt;=============================================================================&lt;/span&gt;   &lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;---------------------------------------&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;br /&gt; &lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;In your trigger you have defined a variable SALARY and used it in the  IF..ELSIF. Since the value of SALARY is NULL (you haven't initialized it) both  the IF and ELSIF will evaluate to FALSE. You need to populate the variable,  probably by querying the INSTRUCTOR table with the ID of the instructor from the  insert. Use the NEW record supplied by the trigger (:new.instructor_id).  &lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;Also, I don't think you want to use the RAISE_APPLICATION_ERROR if the insert  is allowed. Doing so will cause the insert to fail. Perhaps you are just doing  that for testing.  &lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;---------------------------------------&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;============================================================================= &lt;br /&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;CREATE OR REPLACE TRIGGER CHECK_SALARY_TR&lt;br /&gt;BEFORE INSERT&lt;br /&gt;ON AUTH &lt;br /&gt;DECLARE&lt;br /&gt;SALARY INSTRUCTOR.SALARY%TYPE;&lt;br /&gt;BEGIN&lt;br /&gt;IF (SALARY &lt;  3750) THEN&lt;br /&gt;RAISE_APPLICATION_ERROR(-20101,'SORRY, YOU DO NOT HAVE  AUTHORIZATION TO OFFER COURSES');&lt;br /&gt;END IF;&lt;br /&gt;END;&lt;br /&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;============================================================================= &lt;br /&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;CREATE OR REPLACE PROCEDURE INSERT_AUTH_PROC(P_INSTRUCTOR_ID  AUTH.INSTRUCTOR_ID%TYPE,&lt;br /&gt;P_COURSE_ID AUTH.COURSE_ID%TYPE,&lt;br /&gt;P_AUTH_DATE  AUTH.AUTH_DATE%TYPE ) IS&lt;br /&gt;BEGIN&lt;br /&gt;INSERT INTO AUTH(INSTRUCTOR_ID,  COURSE_ID, AUTH_DATE)&lt;br /&gt;VALUES (P_INSTRUCTOR_ID, P_COURSE_ID, P_AUTH_DATE); &lt;br /&gt;END INSERT_AUTH_PROC;&lt;br /&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;=============================================================================   &lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="color: rgb(204, 102, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms; font-weight: bold;"&gt;&lt;span style="color: rgb(204, 102, 0);"&gt;How to modify the trigger coding so that the SALARY can refer to the most  currently inserted new row?&lt;/span&gt;  &lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="color: rgb(153, 51, 153); font-weight: bold; font-style: italic;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="color: rgb(153, 51, 153); font-style: italic; font-weight: bold;"&gt;Example:&lt;/span&gt;&lt;/span&gt; I insert new record into the INSTRUCTOR table where the new  instructor have the SALARY (lessthan) 3750, then when he want to insert himself into  the AUTH table, he can't cause the SALARY (lessthan) 3750 unless his salary change to  more that 3750?  &lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;It can run smoothly if i change the ......  &lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;SALARY INSTRUCTOR.SALARY%TYPE;  &lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;TO BECOME  &lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;SALARY INSTRUCTOR.SALARY%TYPE:=2000; (this will not allow me to insert into  AUTH table)&lt;br /&gt;SALARY INSTRUCTOR.SALARY%TYPE:=5000; (this will allow me to  insert into AUTH table)  &lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;BUT I don't want it to be fix value! I want the trigger to check the SALARY  on the new instructor that i just inserted.  &lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;PROBLEM: I don't really know how to use the :new and :old like what you told  me, if not mistaken, the :new should be only available on "BEFORE INSERT or  update" right.  &lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;---------------------------------------&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;br /&gt; &lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;You're correct, the NEW and OLD are only available to row triggers. Sorry  about that, didn't catch that your trigger was not a row trigger. Could you make  this a row trigger instead? Or, add the validation code to the procedure, prior  to the insert.  &lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;---------------------------------------&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;br /&gt; &lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;Thanks again for your help one more time. I try to implement the technique  that you suggest and now I done perfectly. Thanks.  &lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;Below is the code that run successfully. with make sure of :NEW command &lt;br /&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;=============================================================================&lt;br /&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;CREATE OR REPLACE TRIGGER CHECK_SALARY_TR&lt;br /&gt;BEFORE INSERT&lt;br /&gt;ON AUTH &lt;br /&gt;FOR EACH ROW&lt;br /&gt;DECLARE&lt;br /&gt;V_SALARY INSTRUCTOR.SALARY%TYPE;&lt;br /&gt;BEGIN &lt;br /&gt;SELECT SALARY&lt;br /&gt;INTO V_SALARY&lt;br /&gt;FROM INSTRUCTOR&lt;br /&gt;WHERE INSTRUCTOR_ID  = :NEW.INSTRUCTOR_ID;&lt;br /&gt;IF (V_SALARY lessthanusethatsysmbol 3750) THEN &lt;br /&gt;RAISE_APPLICATION_ERROR(-20101,'SORRY, YOU DO NOT HAVE AUTHORIZATION TO  OFFER COURSES');&lt;br /&gt;END IF;&lt;br /&gt;END;&lt;br /&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;=============================================================================&lt;/p&gt;&lt;br /&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;br /&gt; &lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2967271806809978211-1398596683595949025?l=oracledbs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracledbs.blogspot.com/feeds/1398596683595949025/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2967271806809978211&amp;postID=1398596683595949025' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/1398596683595949025'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/1398596683595949025'/><link rel='alternate' type='text/html' href='http://oracledbs.blogspot.com/2007/12/using-trigger-and-procedure-together.html' title=''/><author><name>Real Time Scenario</name><uri>http://www.blogger.com/profile/11930020132547308855</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2967271806809978211.post-6519124422287336773</id><published>2007-12-07T10:15:00.000-08:00</published><updated>2007-12-07T10:21:08.860-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='What is PL/SQL tables'/><title type='text'></title><content type='html'>&lt;span style="font-size:180%;"&gt;&lt;b&gt;&lt;span style="color: rgb(204, 0, 0);"&gt;&lt;br /&gt;What is PL/SQL  tables?&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;  &lt;p&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;What is PL/SQL tables.  When and why they are  used.&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;  &lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;PL/Sql table is a virtual array(single array) table  defined during runtime.These tables help u in storing,manipulating in a blocks  thus removing the need to connect to the database for information except for the  first time and later can be updated into the database.&lt;/span&gt;  &lt;/p&gt;&lt;p style="font-family: trebuchet ms; color: rgb(153, 0, 0);"&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;Eg&lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;Assume I have a table  emp&lt;/span&gt;  &lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;emp&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;------&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;empno&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;empname&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;empsal&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;saldate&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;empcomm&lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;&lt;br /&gt;&lt;/span&gt;  &lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;Now I would like to give the employees an  increment/commission and will create a procedure with some logic.&lt;/span&gt;  &lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;Create procedure empinc&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;as&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;type v_empsal  is table of  emp%rowtype;&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;cursor as my_empsal is select * from  emp&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;where empsal.empno=emp.empno;&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;begin&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;open my_emp&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;fetch my_emp into v_empsal;&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;exit when my_emp%notfound;&lt;/span&gt;  &lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;for i in v_empsal.first..v_empsal.last&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;loop&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt; if v_empsal is not null  then&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;   v_empsal(i).empcomm:=v_empsal(i).empsal/100*10;&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;   v_empsal(i).empsal=  v_empsal(i).empsal&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;                                    +v_emp(i).empcomm;&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt; end if;&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;end  loop;&lt;/span&gt;  &lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt; begin&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt; forall k in  v_empsal.first..v_empsal.last&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;   insert into  empsal vlaues v_empsal(k)&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt; end;&lt;/span&gt;  &lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;end;&lt;/span&gt;  &lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;In the above example as you see I didn't need to use any  extra valrables nor define any data types. Both of these were as it was defined  in the database and the array takes care of storing the values and insertion of  the details in to the table was done by&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt; the  decalring the table type and the array with in it&lt;/span&gt;  &lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;Anyway you are using the cursor variable, so you can loop across the records  and process one by one. The use of table type variable is not significant.  &lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;When you open the cursor, during first fetch use bulk collect and take the  records into table variables declared. After this close the cursot. YOU NEED NOT  LOOP across the cursor.  &lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;Table type variable is very useful when you need to select in the array.&lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt; &lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;Declare&lt;br /&gt;type empno_list is table of emp.empno%;&lt;br /&gt;empno_list_var  empno_list ;&lt;br /&gt;begin&lt;br /&gt;select empno BULK COLLECT into empno_list_var from&lt;br /&gt;scott.emp where empno &gt; 100 ;  &lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;for v_empno in empno_list_var.first ..&lt;br /&gt;empno_list_var.last&lt;br /&gt;loop&lt;br /&gt;...&lt;br /&gt;;;;&lt;br /&gt;---&lt;br /&gt;end loop;  &lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;end;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt; &lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2967271806809978211-6519124422287336773?l=oracledbs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracledbs.blogspot.com/feeds/6519124422287336773/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2967271806809978211&amp;postID=6519124422287336773' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/6519124422287336773'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/6519124422287336773'/><link rel='alternate' type='text/html' href='http://oracledbs.blogspot.com/2007/12/what-is-plsql-tables-what-is-plsql.html' title=''/><author><name>Real Time Scenario</name><uri>http://www.blogger.com/profile/11930020132547308855</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2967271806809978211.post-4923537626833730912</id><published>2007-12-07T09:40:00.000-08:00</published><updated>2007-12-07T10:13:39.265-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Accessing Oracle Database'/><title type='text'></title><content type='html'>&lt;span style="color: rgb(153, 0, 0); font-style: italic;font-size:180%;" &gt;&lt;br /&gt;Accessing Oracle Database&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;p style="font-family: trebuchet ms;font-family:trebuchet ms;" &gt;&lt;span style="font-size:130%;"&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;I have a oracle database out on my company's network  which I need to access.&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;  &lt;/p&gt;&lt;p style="font-family: trebuchet ms;font-family:trebuchet ms;" &gt;&lt;span style="font-size:130%;"&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;font-family:trebuchet ms;" &gt;&lt;span style="font-size:130%;"&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;1. I have the IP address of where this oracle database  is located.&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;font-family:trebuchet ms;" &gt;&lt;span style="font-size:130%;"&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;2. I have the name of the  database&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;font-family:trebuchet ms;" &gt;&lt;span style="font-size:130%;"&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;3. I have username and  password&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;  &lt;/p&gt;&lt;p style="font-family: trebuchet ms;font-family:trebuchet ms;" &gt;&lt;span style="font-size:130%;"&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;How do I connect to this database. What all do I need  to set up the enviroment on my computer to access this database.&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;span style="font-family: trebuchet ms;font-family:trebuchet ms;font-size:130%;"  &gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0); font-family: trebuchet ms;font-family:trebuchet ms;font-size:130%;"  &gt;&lt;br /&gt;You will need a tnsnames file. And you will some tool to  connect with, either sqlplus, Toad or other similar products. In your tnsnames  file on your machine there must be an entry for that database and ip address or  host name. Then you can use one of the tools such as Toad or sqlplus to connect  to the db. Login with your user name and password and try to connect in one of  those tools or something similar. You can also tnsping the database to make sure  you can reach it. on the command line in dos, c:\tnsping ip_address. Then make  sure it gives you a return so that you know the db is there. This is just to  start out to see if you can reach it.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;p style="font-family: trebuchet ms;font-family:trebuchet ms;" &gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;To access oracle database you need to installed oracle  client software i.e. sqlplus or another tool like TOAD, SQL Navigator  etc.&lt;/span&gt;  &lt;/p&gt;&lt;p style="font-family: trebuchet ms;font-family:trebuchet ms;" &gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;SQL*PLUS is the oracle client software ship along with u  r oracle Enterprice cd. While Installing oracle select Oracle client it will  install sql*plus &amp;amp; sql*net.&lt;/span&gt;  &lt;/p&gt;&lt;p style="font-family: trebuchet ms;font-family:trebuchet ms;" &gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;After Successful Installation Modify your tnsnames.ora  file (resides in ORACLE_HOME/network/adin&lt;/span&gt;  &lt;/p&gt;&lt;p style="font-family: trebuchet ms;font-family:trebuchet ms;" &gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;dir).&lt;/span&gt;  &lt;/p&gt;&lt;p style="font-family: trebuchet ms;font-family:trebuchet ms;" &gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;font-family:trebuchet ms;" &gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;&lt;textarea rows="13" cols="40"&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;db_alias =&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;(DESCRIPTION  =&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;(ADDRESS_LIST =&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;(ADDRESS = (PROTOCOL = TCP)(HOST =  &lt;db&gt;  )(PORT = &lt;db&gt;))&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;)&lt;/span&gt; &lt;br /&gt;&lt;span style="color:#000000;"&gt;(CONNECT_DATA =&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;(SERVICE_NAME = &lt;db&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;)&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;font-family:trebuchet ms;"&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;"&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;font-family:trebuchet ms;"&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;"&gt;&lt;/textarea&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;font-family:trebuchet ms;" &gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;OR&lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;font-family:trebuchet ms;" &gt;&lt;br /&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;"&gt;&lt;span style="color:#000000;"&gt;db_alias =&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;(DESCRIPTION  =&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;(ADDRESS_LIST =&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;(ADDRESS = (PROTOCOL = TCP)(HOST =  ..db server ip address..  )(PORT = ..db server port...))&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;)&lt;/span&gt; &lt;br /&gt;&lt;span style="color:#000000;"&gt;(CONNECT_DATA =&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;(SERVICE_NAME = ...db server sid...)&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;)&lt;/span&gt; &lt;/p&gt;&lt;p style="font-family: trebuchet ms;font-family:trebuchet ms;" &gt;  &lt;/p&gt;&lt;p style="font-family: trebuchet ms;font-family:trebuchet ms;" &gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;After these setting use tnsping on command prompt  :&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;tnsping &lt;/span&gt;..db server sid..  &lt;/p&gt;&lt;span style="font-family: trebuchet ms;font-family:trebuchet ms;font-size:130%;"  &gt;&lt;br /&gt;&lt;/span&gt;&lt;p style="font-family: trebuchet ms;font-family:trebuchet ms;" &gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;If tnsping reply correctly&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;use sqlplus to connect to database&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;sqlplus dbuser/dbpassword@db_alias&lt;/span&gt;&lt;/p&gt;&lt;span style="font-family: trebuchet ms;font-family:trebuchet ms;font-size:130%;"  &gt;&lt;br /&gt;&lt;/span&gt;&lt;p style="font-family: trebuchet ms;" face="trebuchet ms"&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: trebuchet ms;" face="trebuchet ms"&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;span style=";font-family:trebuchet ms;font-size:130%;"  &gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2967271806809978211-4923537626833730912?l=oracledbs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracledbs.blogspot.com/feeds/4923537626833730912/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2967271806809978211&amp;postID=4923537626833730912' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/4923537626833730912'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/4923537626833730912'/><link rel='alternate' type='text/html' href='http://oracledbs.blogspot.com/2007/12/accessing-oracle-database-i-have-oracle.html' title=''/><author><name>Real Time Scenario</name><uri>http://www.blogger.com/profile/11930020132547308855</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2967271806809978211.post-4152925659668114887</id><published>2007-12-07T09:33:00.000-08:00</published><updated>2007-12-07T09:40:02.603-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Referential Integrity'/><title type='text'></title><content type='html'>&lt;b style="color: rgb(153, 0, 0);"&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:180%;"&gt;About Referential  Integrity&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;  &lt;p&gt;First let me brief about the RFforeign key concept.  &lt;/p&gt;&lt;p&gt;If you are thorough on this you will not have this doubt.So letz get going:  &lt;/p&gt;&lt;p&gt;Referential integrity is about ensuring that relationships between rows in  related tables are valid and that you do not accidentally delete or change  related data.  &lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;When referential integrity is enforced in an Oracle database, you must  observe the &lt;span style="font-weight: bold; font-style: italic; color: rgb(204, 102, 0);"&gt;following rules: &lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;1.You cannot enter a value in the  foreign key column of the related table if that value does not exist in the  primary key of the related table. However, you can enter a null in the foreign  key column. For example, you cannot indicate that a job is assigned to an  employee who is not included in the EMPLOYEE table, but you can indicate that an  employee has no assigned job by entering a null in the JOB_ID column of the  EMPLOYEE table.  &lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;2. You cannot delete a row from a primary key table if rows matching  it exist in a related table. For example, you cannot delete a row from the JOBS  table if there are employees assigned to the job represented by that row in the  EMPLOYEE table. However, if cascading deletes are enabled, you can delete a  primary key row; all matching rows in related tables are also deleted.  &lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;3. You cannot change a primary key value in the primary key table if  that row has related rows. For example, you cannot delete an employee from the  EMPLOYEE table if that employee is assigned to a job in the JOBS table.  &lt;/p&gt;&lt;p style="font-weight: bold; color: rgb(0, 0, 102);"&gt;&lt;span style="font-style: italic;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="font-weight: bold; color: rgb(0, 0, 102);"&gt;&lt;span style="font-style: italic;"&gt;Oracle supports only two kinds of referential integrity:&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;1. Enabling referential integrity to check values in related tables when you  enter data. If the data value is not allowed (as determined by the rules above),  the data entry fails and the data is not added to the database.  &lt;/p&gt;&lt;p&gt;2. Cascading deletes.  &lt;/p&gt;&lt;p&gt;By now you should have got the picture!!!  &lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-weight: bold; font-style: italic; color: rgb(204, 0, 0);"&gt;SOME MORE HINTS: &lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;DELETE removes one or more records in a table, checking  referential constraints (to see if there are dependent child records) and firing  any DELETE triggers. In the order you are deleting (child first then parent)  there will be no problems.  TRUNCATE removes ALL records in a table. It does not  execute any triggers.Also, it only checks for the existance (and status) of  another foreign key pointing to the table. If one exists and is enabled, then  you will get your error. This is true even if you do the child tables first.   &lt;/p&gt;&lt;p&gt;You should disable the foreign key constraints in the child tables before  issuing the TRUNCATE command, then re-enable them afterwards.  &lt;/p&gt;&lt;p&gt;Final XPLANATION:  &lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(204, 0, 0); font-style: italic;"&gt;QUESTION:&lt;/span&gt;Suppose I have the tables:Father(A, B, C),Son(X,Y)&lt;br /&gt;Father.Primary Key (A)&lt;br /&gt;Son.Foreign Key (X) refers Father.primarykey(A)&lt;br /&gt;This implies that "Son" table has child records of the parent table  "Father".&lt;br /&gt;Now I'm trying to delete a row using the query:&lt;br /&gt;delete from  Father where A = 123;&lt;br /&gt;          jst as you were asking!!&lt;br /&gt;&lt;/p&gt;&lt;p style="font-weight: bold; font-style: italic;"&gt;&lt;span style="color: rgb(204, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="font-weight: bold; font-style: italic;"&gt;&lt;span style="color: rgb(204, 0, 0);"&gt;So now what  happens?&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="font-weight: bold; color: rgb(0, 102, 0);"&gt;ANS:&lt;/span&gt;Primary and foreign keys are defined the parent/child relationship, you  CANNOT delete a record from parent table until it has record in child table.If  your parent table R1 has any child record oracle does not allow to delete this  parent record because oracle RESPECTS the parent/child relationship.&lt;br /&gt;:+)&lt;br /&gt;&lt;/p&gt;&lt;p&gt;For your future reference you should define keyword ON DELETE CASCADE with  your primary key, this key implicitly delete the child records when you try to  delete parent record.  &lt;/p&gt;&lt;p&gt;But for now the best way is to delete the associative child record of this  primary key from the child table then delete it from parent table.  &lt;/p&gt;&lt;p&gt;for more IDEAS ::::Also look at how to disable/enable constraints!!!!  &lt;/p&gt;&lt;p&gt;A bit too detailed:but hope this helped you.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2967271806809978211-4152925659668114887?l=oracledbs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracledbs.blogspot.com/feeds/4152925659668114887/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2967271806809978211&amp;postID=4152925659668114887' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/4152925659668114887'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/4152925659668114887'/><link rel='alternate' type='text/html' href='http://oracledbs.blogspot.com/2007/12/about-referential-integrity-first-let.html' title=''/><author><name>Real Time Scenario</name><uri>http://www.blogger.com/profile/11930020132547308855</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2967271806809978211.post-555936292188230894</id><published>2007-11-26T23:59:00.001-08:00</published><updated>2007-11-27T00:00:44.958-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='List prerequisites to connect to oracle'/><title type='text'></title><content type='html'>&lt;span style="font-family: verdana;font-size:130%;" &gt;&lt;b style="font-style: italic;"&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;&lt;br /&gt;List prerequisites to connect to oracle  with a administrator previleges&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;  &lt;p&gt;&lt;span style="font-size:130%;"&gt;1.User's O.S account has O.S  previleges.  &lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-size:130%;"&gt;2.The user is granted the SYSDBA or SYSOPER previleges and database user the  password files to authenticate database administration.  &lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-size:130%;"&gt;3.The database has a passsword for the internal login.  &lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-size:130%;"&gt;                                                        oracle server&lt;br /&gt;                                                                 /    \&lt;br /&gt;                                          Oracle database   oracle instance&lt;br /&gt;                                                   /                        \&lt;br /&gt;                             Physical database structure     Logical  database structure&lt;br /&gt;&lt;/span&gt;   &lt;/p&gt;&lt;p&gt;&lt;span style="font-size:130%;"&gt;               (An oracle database's physical structure is datermined by the  O.S files that constitute database)  &lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-size:130%;"&gt;Each oracle database is made of 3 types of files:  &lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-size:130%;"&gt; - one or more datafile&lt;br /&gt;- 2 or  more redo log files&lt;br /&gt;- 1 or more  control files&lt;br /&gt;&lt;/span&gt;   &lt;/p&gt;&lt;p&gt;&lt;span style="font-size:130%;"&gt;&lt;b&gt;Oracle Instance&lt;/b&gt;&lt;br /&gt;System global area(SGA) is an area of memory used  for database admin. shared by the database servers.  &lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-size:130%;"&gt;The combinamtion of the background  process and memory buffers is called an  instance.&lt;br /&gt;&lt;/span&gt;   &lt;/p&gt;&lt;p&gt;&lt;span style="font-size:130%;"&gt;                                            Oracle Instance&lt;br /&gt;                                               /              \&lt;br /&gt;                            User process       Oracle process&lt;br /&gt;                                                           /                \&lt;br /&gt;                                            server process          background process  &lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-size:130%;"&gt;A user process executes the code of an application program or an oracle tool.&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-size:130%;"&gt;Oracle process are server process and background process.&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-size:130%;"&gt;If the user  and server process are on differrent computers of a network, if the user   process connect to hares server process thro' dispatcher process, the user  process and  server process communicate thro' on using  SQL* NET.  &lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-size:130%;"&gt;* Normally tablespace is online than offline.  &lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-size:130%;"&gt;b)Schemas and Schema objects&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-size:130%;"&gt;* Schema is collection objects&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-size:130%;"&gt;* Schema  objects are the logical structures that directly refer to the database's data.   Schema objects include structures as tables,views,sequence.&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-size:130%;"&gt;(There is no  relationship between a tablespace and schema).&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-size:130%;"&gt; 1. table&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-size:130%;"&gt; 2.view - A  view can also be thought of as a stored query.&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-size:130%;"&gt; 3.sequences&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-size:130%;"&gt; 4.program  unit&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-size:130%;"&gt; 5.synonyms&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-size:130%;"&gt; 6.Index,cluster and hash clusters&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-size:130%;"&gt; 7.database link   &lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-size:130%;"&gt;Datablocks, Extents and segments&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-size:130%;"&gt;*one datablock corresponds to a specific  number of bytes of physical database space  on disk.&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-size:130%;"&gt;*An extent is a  specific number of continumous datablock obtained in a single allocation used to  store a specific. &lt;/span&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2967271806809978211-555936292188230894?l=oracledbs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracledbs.blogspot.com/feeds/555936292188230894/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2967271806809978211&amp;postID=555936292188230894' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/555936292188230894'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/555936292188230894'/><link rel='alternate' type='text/html' href='http://oracledbs.blogspot.com/2007/11/list-prerequisites-to-connect-to-oracle.html' title=''/><author><name>Real Time Scenario</name><uri>http://www.blogger.com/profile/11930020132547308855</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2967271806809978211.post-4011701324914964696</id><published>2007-11-26T23:58:00.001-08:00</published><updated>2007-11-26T23:59:10.568-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Problem Running &apos;ckrorole.sql&apos; in Sqlplus'/><title type='text'></title><content type='html'>&lt;span style="font-family: verdana; font-style: italic;font-size:180%;" &gt;&lt;span style="color: rgb(255, 0, 0);"&gt;&lt;br /&gt;Problem Running 'ckrorole.sql' in  Sqlplus&lt;/span&gt;&lt;/span&gt;  &lt;p&gt;&lt;b&gt;I've recently installed my Oracle 9i database and developers suite and  I've created the repository owner and I've created my tablespaces to use in  oracle 9i designer but I'm having problems granting roles to the repository  owner.&lt;/b&gt;  &lt;/p&gt;&lt;p&gt;&lt;b&gt;I can login to sqlplus.exe but I can't seem to run the 'ckrorole.sql' file  which as far as I know is used to grant roles to the repository owner. I keep  getting the following message whenever I try to run it.&lt;/b&gt;  &lt;/p&gt;&lt;p&gt;&lt;b&gt;By the way, I'm using Windows XP.&lt;/b&gt;  &lt;/p&gt;&lt;p&gt;&lt;b&gt;SQL*Plus: Release 9.2.0.1.0 - Production on Fri Oct 22 19:05:07 2004&lt;/b&gt;  &lt;/p&gt;&lt;p&gt;&lt;b&gt;Copyright © 1982, 2002, Oracle Corporation. All rights reserved.&lt;/b&gt;  &lt;/p&gt;&lt;p&gt;&lt;b&gt;Enter user-name: sys@orcl as sysdba&lt;/b&gt;&lt;br /&gt;&lt;b&gt;Enter password:&lt;/b&gt;  &lt;/p&gt;&lt;p&gt;&lt;b&gt;Connected to:&lt;/b&gt;&lt;br /&gt;&lt;b&gt;Personal Oracle9i Release 9.2.0.1.0 -  Production&lt;/b&gt;&lt;br /&gt;&lt;b&gt;With the Partitioning, OLAP and Oracle Data Mining  options&lt;/b&gt;&lt;br /&gt;&lt;b&gt;JServer Release 9.2.0.1.0 - Production&lt;/b&gt;  &lt;/p&gt;&lt;p&gt;&lt;b&gt;SQL&gt; @orahome1\repadm61\utl\ckrorole.sql&lt;/b&gt;&lt;br /&gt;&lt;b&gt;SP2-0310: unable to  open file "orahome1\repadm61\utl\ckrorole.sql"&lt;/b&gt;&lt;br /&gt;&lt;b&gt;SQL&gt;&lt;/b&gt;  &lt;/p&gt;&lt;p&gt;&lt;b&gt;The following happens whenever I try to run it the traditional way.&lt;/b&gt;  &lt;/p&gt;&lt;p&gt;&lt;b&gt;SQL&gt; run d:\orahome1\repadm61\ckrorole.sql&lt;/b&gt;&lt;br /&gt;&lt;b&gt;SP2-0103: Nothing  in SQL buffer to run.&lt;/b&gt;&lt;br /&gt;&lt;b&gt;SQL&gt;&lt;/b&gt;  &lt;/p&gt;&lt;p&gt;&lt;b&gt;What do I need to do to get the 'ckrorole.sql' script to run?&lt;/b&gt;&lt;br /&gt;  &lt;/p&gt;&lt;p&gt;Make sure this: orahome1\repadm61\utl\ is a valid directory -- try specifying  the FULL path.&lt;br /&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;I did check. It is a valid directory. I found the file by  searching for it in the windows XP search companion. The full path for that file  is 'D:\OraHome1\REPADM61\UTL\CKROROLE.SQL'. This is exactly how windows  recognises this file. ('D:\' being the 2nd partition of my 40 Gb Hard drive,  'C:\' being the 1st partition.)&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;What do you mean by 'full path' exactly? Add the 'd:\'  onto the statement?&lt;/span&gt;&lt;br /&gt;  &lt;/p&gt;&lt;p&gt;I found the problem. The code wasn't typed in properly. This is the correct  code:  &lt;/p&gt;&lt;p&gt;@ "D:\OraHome1\REPADM61\UTL\CKROROLE.SQL"  &lt;/p&gt;&lt;p&gt;(Where 'D:' is the letter of the drive or hard disk partition that the  database is installed on)&lt;br /&gt; &lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2967271806809978211-4011701324914964696?l=oracledbs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracledbs.blogspot.com/feeds/4011701324914964696/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2967271806809978211&amp;postID=4011701324914964696' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/4011701324914964696'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/4011701324914964696'/><link rel='alternate' type='text/html' href='http://oracledbs.blogspot.com/2007/11/problem-running-ckrorole.html' title=''/><author><name>Real Time Scenario</name><uri>http://www.blogger.com/profile/11930020132547308855</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2967271806809978211.post-7403731016478722066</id><published>2007-11-26T23:56:00.000-08:00</published><updated>2007-11-26T23:57:58.471-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='one PL/SQL procedure to housekeep a table'/><title type='text'></title><content type='html'>&lt;b&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic; font-family: verdana;font-size:130%;" &gt;Need to write one PL/SQL procedure to  housekeep a table&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;  &lt;p&gt;&lt;b&gt;I'm running Oracle 8.1.7 on Windows 2000 Server.&lt;/b&gt;  &lt;/p&gt;&lt;p&gt;&lt;b&gt;I need to write one PLSQL procedure to housekeep a table, on daily  basis.&lt;/b&gt;  &lt;/p&gt;&lt;p&gt;&lt;b&gt;There are 2 methods i can think of:&lt;/b&gt;&lt;br /&gt;&lt;b&gt;1. Use DBMS_SQL&lt;/b&gt;&lt;br /&gt;&lt;b&gt;...............&lt;/b&gt;&lt;br /&gt;&lt;b&gt;stmt_char := 'DELETE FROM TABLE_A WHERE  TRUNC(DT) &lt;= TRUNC(SYSDATE) - 3'; -- always keep 3 days&lt;/b&gt;&lt;br /&gt;&lt;b&gt;................&lt;/b&gt;&lt;br /&gt;&lt;b&gt;................&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;use&gt;&lt;/use&gt;&lt;/b&gt;  &lt;/p&gt;&lt;p&gt;&lt;b&gt;2. Use cursor&lt;/b&gt;&lt;br /&gt;&lt;b&gt;.............&lt;/b&gt;&lt;br /&gt;&lt;b&gt;CURSOR lv_delete_cur  IS&lt;/b&gt;&lt;br /&gt;&lt;b&gt;SELECT column_A FROM TABLE_A -- where column_A is primary key&lt;/b&gt;&lt;br /&gt;&lt;b&gt;WHERE TRUNC(dt) &lt;= TRUNC(SYSDATE) - 3;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;.............&lt;/b&gt;&lt;br /&gt;&lt;b&gt;.............&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;loop&gt;&lt;/loop&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;..............&lt;/b&gt;  &lt;/p&gt;&lt;p&gt;&lt;b&gt;My questions are:&lt;/b&gt;&lt;br /&gt;&lt;b&gt;(a) Between approach 1 and 2, which is  faster/better performance?&lt;/b&gt;&lt;br /&gt;&lt;b&gt;(b) In terms of performance, is there any  difference if i modify to commit every 500 or 5000 records?&lt;/b&gt;&lt;br /&gt;&lt;b&gt;(c)  Actually, currently i m using approach 1, which is considerably very slow!!!&lt;/b&gt;&lt;br /&gt;&lt;b&gt;[needs 5 - 7 hours to delete approx. 250000 records from table consisting  approx. 800000 records.]&lt;/b&gt;&lt;br /&gt;  &lt;/p&gt;&lt;p&gt;You can go for Dynamic SQL also and probably it helps you to improve the  performance.  &lt;/p&gt;&lt;p&gt;The performance of native dynamic SQL in PL/SQL is comparable to the  performance of static SQL because the PL/SQL interpreter has built-in support  for native dynamic SQL. Therefore, the performance of programs that use native  dynamic SQL is much better than that of programs that use the DBMS_SQL package.  Typically, native dynamic SQL statements perform 1.5 to 3 times better than  equivalent statements that use the DBMS_SQL package. Of course, your performance  gains may vary depending on your application.  &lt;/p&gt;&lt;p&gt;The DBMS_SQL package is based on a procedural API and, as a result, incurs  high procedure call and data copy overhead. For example, every time you bind a  variable, the DBMS_SQL package copies the PL/SQL bind variable into its space  for later use during execution. Similarly, every time you execute a fetch, first  the data is copied into the space managed by the DBMS_SQL package and then the  fetched data is copied, one column at a time, into the appropriate PL/SQL  variables, resulting in substantial overhead resulting from data copying. In  contrast, native dynamic SQL bundles the statement preparation, binding, and  execution steps into a single operation, which minimizes the data copying and  procedure call overhead and improves performance.  &lt;/p&gt;&lt;p&gt;for e.g&lt;br /&gt;BEGIN&lt;br /&gt;EXECUTE IMMEDIATE 'TRUNCATE TABLE my_table;';&lt;br /&gt;END;&lt;br /&gt;/  &lt;/p&gt;&lt;p&gt;Please let me know if any issues&lt;br /&gt;  &lt;/p&gt;&lt;p&gt;&lt;b&gt;I want to share a few ideas..&lt;/b&gt;&lt;br /&gt;&lt;b&gt;first of all you have  said:&lt;/b&gt;  &lt;/p&gt;&lt;p&gt;&lt;b&gt;I need to write one PLSQL procedure to housekeep a table, on daily  basis&lt;/b&gt;  &lt;/p&gt;&lt;p&gt;&lt;b&gt;here ,the question is why PLSQL procedure...as Tom Kyte would say often,we  should use sql instead of pl/sql whereever possible...now here i think you can  definately use simple sql statement like this.&lt;/b&gt;  &lt;/p&gt;&lt;p&gt;&lt;b&gt;DELETE FROM TABLE_A WHERE TRUNC(DT) &lt;= TRUNC(SYSDATE) - 3&lt;/b&gt;  &lt;/p&gt;&lt;p&gt;&lt;b&gt;the thing to watch here is whether any indexes are being used or not....is  there an index on the column DT?&lt;/b&gt;&lt;br /&gt;&lt;b&gt;pl post the execution plan of the  query.&lt;/b&gt;&lt;br /&gt;&lt;b&gt;they might not get used i guess and you may need function  based index as you are using the function trunc on the column DT.&lt;/b&gt;&lt;br /&gt;&lt;b&gt;alternately ,just for experiment try the following sql statement (pl.  rollback the results ,as this is just experiment)&lt;/b&gt;&lt;br /&gt;&lt;b&gt;(pl. index the DT  column if not already indexed)&lt;/b&gt;&lt;br /&gt;&lt;b&gt;DELETE FROM TABLE_A WHERE DT &lt;=  SYSDATE - 4&lt;/b&gt;  &lt;/p&gt;&lt;p&gt;&lt;b&gt;see if there is some performance gain.&lt;/b&gt;  &lt;/p&gt;&lt;p&gt;--------------------------------------------------------------------------------------------------------------------------------&lt;br /&gt;Basically I do agree with your saying, but if i use dynamic sql, how do i  perform commit for every 1000 records (deleted), like wat i have explained in my  first post?&lt;br /&gt;--------------------------------------------------------------------------------------------------------------------------------&lt;br /&gt;Perhaps i have tried most with and without TRUNC function, but the  performance seems almost the same. Fyi, the DT column is indexed. But i guess u  should not use:  &lt;/p&gt;&lt;p&gt;DELETE FROM TABLE_A WHERE DT &lt;= SYSDATE - 4  &lt;/p&gt;&lt;p&gt;bcoz it is not accurate. If you really want to get rid off the TRUNC, i  supposed you should use:  &lt;/p&gt;&lt;p&gt;lv_sysdate_date := TRUNC(SYSDATE);  &lt;/p&gt;&lt;p&gt;DELETE FROM TABLE_A WHERE DT &gt;= lv_sysdate_date - 3 AND DT &lt;&gt;&lt;/p&gt;&lt;p&gt;Please correct me, if i am wrong.  &lt;/p&gt;&lt;p&gt;And to your question why am i using PL/SQL instead of SQL statement. This is  bcoz:&lt;br /&gt;(a) Actually the "3" as in "TRUNC(dt) &lt;= TRUNC(SYSDATE) - 3", i  need to query from another table. It is not hardcoded. (b) I need to commit  after 1000 records have been deleted, due to rollback segment issue.  &lt;/p&gt;&lt;p&gt;--------------------------------------------------------------------------------------------------------------------------------   &lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;Can u pl. post the execution plan of the query? what i  would like to see is ,whether the index is being used or not..in fact i think  that the index may not be used if this is not a function based index..so could u  pl. post the execution plan of the query.for commiting,if i understand  correctly,it really does not matter whether you commit after 1000 records or  10000 records..so don't expect any big gain in performance from that  area...&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;Thats what i feel...key factor is ensuring &amp;amp;  verifying that index is being used.also try NOT to use the index and see  performance..and explain plan and post it and try TO USE the index and see  performace and post the explain plan..i would like to compare the two  plans..(PL. ROLLBACK if u are just experimenting)&lt;/span&gt;&lt;br /&gt; &lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2967271806809978211-7403731016478722066?l=oracledbs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracledbs.blogspot.com/feeds/7403731016478722066/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2967271806809978211&amp;postID=7403731016478722066' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/7403731016478722066'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/7403731016478722066'/><link rel='alternate' type='text/html' href='http://oracledbs.blogspot.com/2007/11/need-to-write-one-plsql-procedure-to.html' title=''/><author><name>Real Time Scenario</name><uri>http://www.blogger.com/profile/11930020132547308855</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2967271806809978211.post-7878648782188611618</id><published>2007-11-26T23:51:00.000-08:00</published><updated>2007-11-26T23:56:12.302-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Use user defined functions in SQL'/><title type='text'></title><content type='html'>&lt;b&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: verdana;font-size:180%;" &gt;Use user defined functions in SQL  statements&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;  &lt;p&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;Can we use user definbed functions in SQL statements,  as we can use in built oracle function like date etc..?&lt;/span&gt;&lt;/b&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;Yeah.Of course provided there is no dml in your  function&lt;/span&gt;&lt;br /&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;Thanks for reply, pls tell you can't we use functions  with DML in it. What will hapen if it conatins dml in it.&lt;/span&gt;&lt;br /&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;We can use function which has only select statments in  it, but it should not contain other DML statements like INSERT,UPDATE and DELETE  oracle doesnot allow because it might get conflicts&lt;/span&gt;&lt;br /&gt;  &lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;Add A Function To User Defined  Object&lt;/span&gt;&lt;/b&gt;  &lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;DATABASE: Oralce 9i&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;TOOL : OEM 9.2.0.1.0&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;Can I  add a Function to a User Defined Object Type.&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;The User Defined Object Has Dependencies.&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;I tried adding the function using OEM but an error was  reported,says, cannot alter the definition.&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;I tried Oracle Change Manager,but that does not display User  defined Types.&lt;/span&gt;&lt;/b&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;This is well explained in the Oracle manuals. You cannot  simple modify the already existing object type. In order to modify object  attributes or methods, an object type must be dropped and re-created. An attempt  to drop or replace a type with type or table dependents will result in an  ORA-02303. Here is the manual part:&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;QUOTE:&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;The object types  can be instantiated as types (nested tables or VARRAYs) or object tables. If  data preservation is required, data depending on the type must be manually moved  into temporary tables.&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;Per the SQL Reference  guide, the DROP TYPE FORCE option is not recommended since this operation is not  recoverable and could cause the data in the dependent tables to become  inaccessible.&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;The following 3 queries can be run to determine  dependencies:&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;-- Find nested tables&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;select owner, parent_table_name, parent_table_column&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;  from dba_nested_tables&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;where (table_type_owner, table_type_name) in&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;(select owner, type_name&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;from  dba_coll_types&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;where elem_type_owner =  '&lt;typeowner&gt;'&lt;/typeowner&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;and elem_type_name =  '&lt;typename&gt;');&lt;/typename&gt;&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;-- Find VARRAYs&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;select  owner, parent_table_name, parent_table_column&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;from dba_varrays&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;where (type_owner,  type_name) in&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;(select owner, type_name&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;from dba_coll_types&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;where  elem_type_owner = '&lt;typeowner&gt;'&lt;/typeowner&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;and  elem_type_name = 'typename');&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;-- Find object tables&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;select owner, table_name&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;from  dba_object_tables&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;where table_type_owner =  'typeOwner'&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;and table_type =  'typeName.'&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;and nested = 'NO';&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;So first find the object dependencies on object types,  make sure you have a means to backup the dependent object (nested tables,  varrays, tables), drop the dependent object (nested tables, varrays, tables),  modify the object type, re-create (restore) the object (nested tables, varrays,  tables).&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;Hope that works for you - no OEM involved, so it would be  a good practice.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt; &lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2967271806809978211-7878648782188611618?l=oracledbs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracledbs.blogspot.com/feeds/7878648782188611618/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2967271806809978211&amp;postID=7878648782188611618' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/7878648782188611618'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/7878648782188611618'/><link rel='alternate' type='text/html' href='http://oracledbs.blogspot.com/2007/11/use-user-defined-functions-in-sql.html' title=''/><author><name>Real Time Scenario</name><uri>http://www.blogger.com/profile/11930020132547308855</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2967271806809978211.post-191384966918493128</id><published>2007-11-26T23:49:00.000-08:00</published><updated>2007-11-26T23:50:46.725-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Update statements in Query'/><title type='text'></title><content type='html'>&lt;span style="font-size:180%;"&gt;&lt;b&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;&lt;br /&gt;Update statements in  Query&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;  &lt;p&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;I have one query,&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;Update the salary of the employees who has finished one year  service with the company by 10% and who has service less than 1 yr with the  company by only 5%.&lt;/span&gt;&lt;/b&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;Thesre are basically two Update statements in your  Query:&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;1. Update the salary of the employees who has finished  one year service with the company by 10%&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;Ans:&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;update table employee  set salary = (salary + 0.10*salary) where  (to_number(to_char(sysdate,'YYYY'))&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;-  to_number(to_char(hiredate,'YYYY'))) &gt; 1&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;/&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;2. and who has service less than 1 yr with the company   by only 5%&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;Ans:&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;Update table employee  set salary = (salary + 0.05*salary) where  (to_number(to_char(sysdate,'YYYY'))&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;-  to_number(to_char(hiredate,'YYYY'))) &lt;&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;/&lt;/span&gt;  &lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;I think this is what you needed else revert me  back.&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;..............&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;Use  Decode or  Case to solve this  problem&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;.............&lt;/span&gt;&lt;/b&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;Give this inside a loop&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;UPDATE empincrement&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;SET salincrement =&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;                (&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;                 SELECT decode(doj - sysdate  &gt;=1 ,sal*.10, sal*.05)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;                 FROM emp&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;                );&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;end loop&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;This is the way I have tried to solve this, but in the  below part&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;doj - sysdate  &gt;=1 , its giving an  error like right paranthesis missing.&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;...........&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;Use this query in your loop.&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;update emp&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;set sal=&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;(SELECT case when (hiredate - sysdate) &gt;=1  then&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;sal*.10 else sal*.05 end&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;FROM emp)&lt;/span&gt; &lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2967271806809978211-191384966918493128?l=oracledbs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracledbs.blogspot.com/feeds/191384966918493128/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2967271806809978211&amp;postID=191384966918493128' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/191384966918493128'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/191384966918493128'/><link rel='alternate' type='text/html' href='http://oracledbs.blogspot.com/2007/11/update-statements-in-query-i-have-one.html' title=''/><author><name>Real Time Scenario</name><uri>http://www.blogger.com/profile/11930020132547308855</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2967271806809978211.post-5989473774919074364</id><published>2007-11-26T23:40:00.000-08:00</published><updated>2007-11-26T23:48:57.877-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Why this Query Returns null'/><title type='text'></title><content type='html'>&lt;b&gt;&lt;span style="color:#ff0000;"&gt;&lt;span style="font-size:+2;"&gt;&lt;br /&gt;Why this Query Returns  null&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;  &lt;p&gt;&lt;b&gt;&lt;span style="color:#000000;"&gt;Why this query returns null?  Why rownum does not work  with equality?&lt;/span&gt;&lt;/b&gt;  &lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;span style="color:#000000;"&gt;select * from emp where rownum = 10;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;SQL&gt; select rowid,rownum from emp ;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;ROWID                  ROWNUM&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;------------------ ----------&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;AAAHcIAABAAAMuiAAA          1&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;AAAHcIAABAAAMuiAAB          2&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;AAAHcIAABAAAMuiAAC          3&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;AAAHcIAABAAAMuiAAD          4&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;AAAHcIAABAAAMuiAAE          5&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;AAAHcIAABAAAMuiAAF          6&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;AAAHcIAABAAAMuiAAG          7&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;AAAHcIAABAAAMuiAAH          8&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;AAAHcIAABAAAMuiAAI          9&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;AAAHcIAABAAAMuiAAJ         10&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;AAAHcIAABAAAMuiAAK       ! 11&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;ROWID                  ROWNUM&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;------------------ ----------&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;AAAHcIAABAAAMuiAAL         12&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;AAAHcIAABAAAMuiAAM         13&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;AAAHcIAABAAAMuiAAN         14&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;AAAHcIAABAAAMuiAAO         15&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;AAAHcIAABAAAMuiAAP         16&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;16  rows selected.&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;SQL&gt; select * from emp where  rowid='AAAHcIAABAAAMuiAAJ' ;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;     EMPNO  ENAME           JOB              MGR HIREDATE         SAL       COMM&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;---------- --------------- --------- ----------  --------- ---------- ----------&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;    DEPTNO&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;----------&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;      7844  TURNER          SALESMAN        7698 08-SEP-81       1500          0&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;        30&lt;/span&gt;  &lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;What I inquire is only this rowid is changed to rownumber for the userfriendly environment..and in order to retrieve it we should use only this rowid..This is what i feel and i may be right or wrong.just want to share what i feel.&lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;span style="font-weight: bold;"&gt;.............&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="color:#000000;"&gt;Rownum is not stored in database, it is a pseudocolumn, and generated only when we try to retrieve data from the tables. oracle assigns the sequential number in the same order it retrieves the records from the table.&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;Now if you use "&lt;" then oracle can find out the records rownum and returns the records. while in case of equality, its not possible to identify a record order in which it is going to be returned.&lt;/span&gt; &lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;span style="font-weight: bold;"&gt;.........&lt;/span&gt;&lt;br /&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;Its wrong query&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt; &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;select * from emp where rownum = 10;&lt;/span&gt;  &lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;Right query is : select * from emp where (cloumn name) =  10;&lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-weight: bold;"&gt;...............&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="color:#000000;"&gt;To remove duplicate rows using rownum,  do the  following:&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt; &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;select rownum, ...column name.. from ...table name..;&lt;/span&gt; &lt;br /&gt;&lt;span style="color:#000000;"&gt; &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;you will get the list  of records with unique rownum. Even the duplicate records will have different  rownum.&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt; &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;Now, you  can use the DELETE statement to remove one of the duplicate record.&lt;/span&gt; &lt;br /&gt;&lt;span style="color:#000000;"&gt; &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;delete ....table  name.. where  rownum= X;  ( where X is the rownum of the duplicate  record)&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt; &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;Hope you  have understood!!!&lt;/span&gt;&lt;br /&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="color:#000000;"&gt; &lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2967271806809978211-5989473774919074364?l=oracledbs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracledbs.blogspot.com/feeds/5989473774919074364/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2967271806809978211&amp;postID=5989473774919074364' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/5989473774919074364'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/5989473774919074364'/><link rel='alternate' type='text/html' href='http://oracledbs.blogspot.com/2007/11/blog-post.html' title=''/><author><name>Real Time Scenario</name><uri>http://www.blogger.com/profile/11930020132547308855</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2967271806809978211.post-439434371495759006</id><published>2007-11-26T23:36:00.001-08:00</published><updated>2007-11-26T23:37:31.012-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Query about Data Storage and Retrieval'/><title type='text'></title><content type='html'>&lt;b&gt;&lt;span style="color: rgb(204, 0, 0);"&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;span style="color: rgb(204, 0, 0); font-family: verdana;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-size:180%;"&gt;Query about Data Storage and  Retrieval&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;  &lt;p&gt;&lt;b&gt;Is there any database parameter that we can set, which controls the way  data is stored and retrieved for display purpose.&lt;/b&gt;  &lt;/p&gt;&lt;p&gt;&lt;b&gt;Or to put it other way round,&lt;/b&gt;  &lt;/p&gt;&lt;p&gt;&lt;b&gt;When we retrieve the data using select * statement, is the data displayed  always in the chronological order ?&lt;/b&gt;  &lt;/p&gt;&lt;p&gt;&lt;b&gt;Context here is:&lt;/b&gt;  &lt;/p&gt;&lt;p&gt;&lt;b&gt;We have a table that contains past 2 months data (say 200 rows - 100 rows  loaded on 1st June as May data, 100 for June data loaded on 1st July). Using  some DB feature/parameter can we seprate out the recently inserted rows i.e.  June data ?&lt;/b&gt;  &lt;/p&gt;&lt;p&gt;&lt;b&gt;PS: there is no date-time stamp related column in the row.&lt;/b&gt;  &lt;/p&gt;&lt;p&gt;&lt;b&gt;Just a blind shot:&lt;/b&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;If I do select * from table, and copy the  last 100 of the displayed records, will it always serve my objective?&lt;/b&gt;&lt;br /&gt;  &lt;/p&gt;&lt;p&gt;When you want to querry data from a table you have to know the structure of  the table(i.e the columns in the table) these are what you need to restrict your  select.&lt;br /&gt;&lt;br /&gt;For example if you have a table called urtable has column like&lt;br /&gt;&lt;br /&gt;name&lt;br /&gt;address&lt;br /&gt;salary&lt;br /&gt;date_loaded&lt;br /&gt;&lt;br /&gt;You can query  for data loaded in june this way:&lt;br /&gt;&lt;br /&gt;select  name,address,salary,date_loaded from urtable&lt;br /&gt;where date_loaded like  '%06-01-2005%'&lt;br /&gt;&lt;br /&gt;You can play around with several this query to achieve  your desired result.&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2967271806809978211-439434371495759006?l=oracledbs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracledbs.blogspot.com/feeds/439434371495759006/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2967271806809978211&amp;postID=439434371495759006' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/439434371495759006'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/439434371495759006'/><link rel='alternate' type='text/html' href='http://oracledbs.blogspot.com/2007/11/query-about-data-storage-and-retrieval.html' title=''/><author><name>Real Time Scenario</name><uri>http://www.blogger.com/profile/11930020132547308855</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2967271806809978211.post-6836688897960026919</id><published>2007-11-26T23:34:00.000-08:00</published><updated>2007-11-26T23:36:16.678-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Finding How Much Data Has Been Filled'/><title type='text'></title><content type='html'>&lt;b&gt;&lt;span style="color: rgb(204, 0, 0);"&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;span style="color: rgb(204, 0, 0); font-weight: bold;font-size:180%;" &gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-family: verdana;"&gt;Finding How Much Data Has Been  Filled&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;  &lt;p&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;I would like to know how can one identify the current  location that oracle is writing for transaction ie. extent location has reached  the maximum allocated for it within the tablespace.&lt;/span&gt;&lt;/b&gt;  &lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;In plain words finding if the extents have reached the  maxextent?&lt;/span&gt;&lt;/b&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;-----&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;You can use the  view dba_extents and dba_tables for that&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;CODE&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;select b.table_name,a.used,b.max_extents-a.used remaining  from&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;(select segment_name,count(extent_id) used  from dba_extents group by segment_name) a,&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;(select table_name,max_extents from dba_tables) b&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;where a.segment_name=b.table_name&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;-----&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;Are you sure extent_id identifies the used extents?&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;I thought its just an identification&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;-----&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;extent_id  identifies extents that are allocated to the table. so  max_extents-count(extend_id) would give the number of extents yet to be  allocated.&lt;/span&gt;  &lt;/p&gt;&lt;p style="color: rgb(153, 51, 153); font-weight: bold; font-style: italic;"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;That is what you wanted to know? isn't it?&lt;/span&gt; &lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2967271806809978211-6836688897960026919?l=oracledbs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracledbs.blogspot.com/feeds/6836688897960026919/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2967271806809978211&amp;postID=6836688897960026919' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/6836688897960026919'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/6836688897960026919'/><link rel='alternate' type='text/html' href='http://oracledbs.blogspot.com/2007/11/finding-how-much-data-has-been-filled-i.html' title=''/><author><name>Real Time Scenario</name><uri>http://www.blogger.com/profile/11930020132547308855</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2967271806809978211.post-8278794306121541993</id><published>2007-11-26T23:30:00.000-08:00</published><updated>2007-11-26T23:34:20.885-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Time Left For Query Completion'/><title type='text'></title><content type='html'>&lt;span style="color: rgb(204, 0, 0); font-style: italic;font-family:verdana;font-size:180%;"  &gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;br /&gt;Find How Much Time Left For Query  Completion&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;  &lt;p&gt;&lt;span style="font-size:130%;"&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;Need to find out how long will a query take to run or  when I am running the query where can I check to see that X% of my query is  complete.&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="font-size:130%;"&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;I know there is some place in Oracle Enterprise  manager or something like that which shows a progress bar once the query is  started, but I dont exactly recollect it can somebody help me with  this..&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="font-size:130%;"&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;Also when do we run analyze plan estimate statistics  and how does this help if I have to run a complex query. does estimating  statistics on a table increase the query performance if so how ?&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="color: rgb(204, 102, 0);"&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;You can use this query to find out the information you  want to know:&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;CODE&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;REM  Displays the long running operations&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;SET LINESIZE 200&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;COLUMN operation FORMAT a15&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;COLUMN username FORMAT a15&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;COLUMN  object FORMAT a25&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;SELECT a.sid,&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;       a.serial#,&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;      b.username ,&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;      opname OPERATION,&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;       target OBJECT,&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;      TRUNC(elapsed_seconds, 5)  "ET (s)",&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;      TO_CHAR(start_time, 'HH24:MI:SS')  start_time,&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;      ROUND((sofar/totalwork)*100, 2)  "COMPLETE (%)"&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt; FROM v$session_longops a,&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;      v$session b&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;WHERE  a.sid = b.sid AND&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;     b.username not IN ('SYS',  'SYSTEM') AND&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;     totalwork &gt; 0&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;ORDER BY elapsed_seconds;&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;Needed some clrafication regrding this&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;"when do we run analyze plan estimate statistics and how  does this help if I have to run a complex query. Does estimating statistics on a  table increase the query performance if so how ?"&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(153, 51, 153);font-size:130%;" &gt;Your last post contains three questions:&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;1&gt;when I am running the query where can I check to see that X%  of my query is complete&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;2&gt;predict the time to  answer of a query&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;3&gt;estimating statistics on a  table increase the query performance if so how ?&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;My point of view is&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;1&gt;Answers to the first question have given above..&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;2&gt;The second and the third questions implie to  understand what is a CBO (cost based optimizer) and a RBO (rule based  optimizer). Are you familiar with that? The ROB might not be used any more by  oracle (it is an another story). You cannot predict the time of answer of a sql  request. There are too many factors.&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;3&gt;Regarding the third question, the Analyze is useful  if the sql request is analyzed by the COB engine. And it should be.&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;Yes, Analyzing the table allows oracle to know the  volume and the repartition of the tables. Therefore it performs the appropriate  tasks to compute the data together. But sometimes some complex sql requests are  not really well written. In that case you need to analyze the plan table.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2967271806809978211-8278794306121541993?l=oracledbs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracledbs.blogspot.com/feeds/8278794306121541993/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2967271806809978211&amp;postID=8278794306121541993' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/8278794306121541993'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2967271806809978211/posts/default/8278794306121541993'/><link rel='alternate' type='text/html' href='http://oracledbs.blogspot.com/2007/11/find-how-much-time-left-for-query.html' title=''/><author><name>Real Time Scenario</name><uri>http://www.blogger.com/profile/11930020132547308855</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2967271806809978211.post-8255985395606049664</id><published>2007-11-26T23:26:00.001-08:00</published><updated>2007-11-26T23:30:37.666-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='java.sql.SQLException'/><title type='text'></title><content type='html'>&lt;span style="font-size:100%;"&gt;&lt;b&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;&lt;span style="font-style: italic; font-family: verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;span style="color: rgb(255, 0, 0); font-style: italic; font-weight: bold; font-family: verdana;font-size:180%;" &gt;&lt;span style="font-family: verdana;"&gt;&lt;br /&gt;java.sql.SQLException:  ORA-12154&lt;/span&gt;&lt;/span&gt;&lt;b&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;  &lt;p&gt;&lt;span style="font-size:100%;"&gt;&lt;b&gt;&lt;span style="color: rgb(102, 102, 0);"&gt;We are getting java.sql.SQLExcepti
