You are on page 1of 17
32. During modifying a colamn You can change the data type only if the column contains ull values 33. You can convert a CHAR column to the VARCHAR? data type or convert a VARCHAR? column to the CHAR data type only if the column contains null values ot if you do net change the size. 34. A change to the default value of a column affects only subsequent insertions to the table. 49. Using the ALTER TABRIV iain dey shat@ubiatean be dropped at time and the table must have atleast one column remaining ie it after i is 36. You can add a cocimeat of up to 2000 bytes about a column, table. view or sapibot ‘by using the COMMENT statement. 37. You can define any constraint atthe Table level except NOT NULL which is defined only at columa level 38. Without the ON DELETE CASCADE or the ON DELETE SET NULL options, the Row in the parent table cannot be deleted if it is referenced inthe child table, 39. You can add a NOT NULL constraint to an existing column by using the MODIFY clause of the ALTER TABLE statement. 40. You can define a NOT NULL column only if the table is empty o¢ ifthe column has a value for every row 41. A View can be modifying by using the CREATE or REPLACE option. 42 When you diop a table, comesponding indexes are also dropped 33. You can convert a CHAR column to the VARCHAR? data type or convert a VARCHAR? column to the CHAR data type oly if the column contains null values of if you donot change the size. 34. A change to the default value of a column affects only subsequent insertions to the table 35. Using the ALTER TABLE statement. only one column can be dropped at time and ‘the table must have at least one column remaaning im it after it is altered, 36. You can add a comment of up to 2000 bytes about a column, table. view or snapshot by using the COMMENT statemient 37. You can define any constraint at the Table level exeept NOT NULL which is defined oaly at column level. 38, Without the ON DELETE CASCADE or the ON DELETE SET NULL options, the ‘Row in the parent table cannot be deleted if it is referenced in the child table. 39. You can add a NOT NULL constraint to an existing column by using the MODIFY neh amie 40. You can define a NOT NULL é DE cape oe if the column basa value for every row 41. A View can be modifying by using the CREATE or REPLACE option. 42. When you drop a table, corresponding indexes are also dropped. 43. More Indexes on a table does not mean faster queries. Each DML operations that is committed on a table with indexes must be updated, The more indexes you have associated with a table, the more effort the oracle server must make to update all the indexes after a DML operation 44. You cannot modify indexes, To change an Index, you must drop it and the recreates it 45. Ifyou drop a table, Indexes and Constraints are sutomatically dropped but Views and ‘Sequences remains. 46. A user can have access to several Roles and several users can be assigned the same Role. Roles are typically created for database application. 47. As owner of a table can crant access to all users by using the PUBLIC kevword. 33. You can convert a CHAR column to the VARCHAR? data type or convert a VARCHAR? column to the CHAR data type oaly if the column contains null values or if you do not change the size 34. A-change to the default valve of a column affects only subsequent insertions to the table. 35. Using the ALTER TABLE statement, only one column can be dropped at time and the tnble must have at least one column remaining in it after it is altered. 36. You can add a comment of up to 2000 bytes about a column, table. view or snapshot by using the COMMENT statement 37. You can define any constraint at the Table level except NOT NULL which is defined only at columa level 38. Without the ON DELETE CASCADE or the ON DELETE SET NULL options, the Row in the parent table cannot be deleted if it is referenced in the ehild table. 39. You can add a NOT NULL constraint to an existing columa by using the MODIFY clause of the ALTER Ty 40. You can define a NOT S DE cape of the column basa value for every row 41. A View can be modifying by using the CREATE or REPLACE option 43. More ‘on atable does: faster queries. Each tions that is. ene eet ee eee associated with a table, the more effort the oracle server must make to update all the indexes after a DML operation. 44. You cannot modify indexes, To change an Index, you must drop it and the recreates it 45. Ifyou drop a table, Indexes and Constraints are sutomatically dropped but Views and ‘Sequences remains. 46. A user can have accessto several Roles and several users can be assigned the same Role. Roles are typically created for database application, 47. As owner of a table can crant access to all users by using the PUBLIC kevword. 39, You can add a NOT NULL constraint to an existing column by using the MODIFY clause of the ALTER TABLE statement. 40. You can define a NOT NULL column only if the table is empty or if the column has a value for every row 41. A View can be modifying by using the CREATE or REPLACE option. 42, When you drop a table, corresponding indexes aze also dropped. 43. More Indexes on a table does not mean faster queries, Each DML operations that is ‘commuted on. a table with indexes must be updated The more indexes you have associated with a table, the more effort the oracle server must make to update all the indexes after a DML operation. 44. You cannot modify indexes. To change an Index, you must drop it and the recreates it, 45, Ifyou drop a table, Indexes and Constraints are automatically dropped but Views and Sequences remains 46, A user can have access to several Roles and several users can be assigned the same Role. Roles are typically syaated fg 47 Annet of uve can PENCE HOU) Stan PUBLIC eywoed 48. Privileges cannot be granted on remote objects 49. You cannot alter the check constraint value, mstead need to drop and create the check ‘constraint again with new value, 50. PLISQL Engine processes the entire PLISQL block and filters out the SQL and procedural Statements separately, this reduces the amount of work that is sent to the oracle server and the number of memory cursors that are required. 51. PLISQL code can be stored in oracle server as sulbprograms and can be referenced by any number of applications that are connected to the database. 52. In PL/SQL, an error is called an Exception. 53. using NOT NULL of CONSTANT with variable declaration, you must assign & value to it $4. To assign a value into a variable from a database, use SELECT or FETCH statements. 59. A slash (/\-rans the PL/SOL block 1m a scriot file or in some tools kuch as iSOL "Plus. Procecurai Sintements separately, this fequces the amount OF Work that 15 sent to te oracle server and the number of memory cursors that are required. 31, PLSQL code ean be stored in oracle server as subprograms and can be referenced by any number of applications that are connected to the database 52. In PLISQL, an extor is called an Exception. 53. using NOT NULL or CONSTANT with variable declaration, you must assign a value to it. $4. To assign a value into a variable from a database, use SELECT or FETCH statements. 55. A slash () rons the PL'SQL block in a script file or in some tools such as iSQL*Phus. 56, DECODE and Group Functions (Axg, Sum, Min, Max, Count, Sides, Variance) are not available im procedural statements. Can be used in an SQL statement in a PL/SQL block. 57. An exception section can contain nested blocks. 38. The Scope of the identificr is that region of a program unit (block, subprogram, o package) from which you caa reference the identifier. www.thundershare.net 59. PL/SQL does not directly support DDL statements such as Create . Alter, Drop table 60. PLISQL does not dieeetly support DCL statements such as GRANT and REVOKE 61. PL/SOL supports DML (Insert. Update. Delete) and Transaction control commands of 46. A ser can have access to several Roles and several users can be assigned the same Role. Roles are typically created for database application. 47, An owner of a table can grant access to all users by using the PUBLIC keyword 48. Privileges cannot be granted on remote objects 49. You cannot alter the check constraint value, mstead need to drop and create the check constraint again with new value. 50, PLISQL Engine processes the entire PL/SQL block and filters out the SQL and procedural Statements separately, this reduces the amouat of work that is sent to the oracle server and the number of memory cursors that are required. SL. PL/SQL code can be stored in oracle server as subprograms and can be referenced by any number of applications that are connected to the database, 52. In PL/SQL, an error is called an Exception. 53. Ifusing NOT NULL of CONSTANT with variable declaration, you must assign a value to it. 54. To assign a value into ‘ot FETCH statements 55. A slash (/) runs the PL’ PMLA EAE i sae 56. DECODE and Group Functions (Avg. Sum, Min, Max, Cows, Shes, Wi sot available in procedural sacement. Can be used in an SQL statement ina PL'SQL Block. 57. Aan exception section can contain nested blocks. 38. The Scope of the identifier 1s that region of a program unit (block, subprogram, or package) from which you can reference the identifier. 59. PL/SQL does not directly support DDL. statements such as Create. Alter, Drop table. 60, PL/SQL. does not directly support DCL statements such as GRANT and REVOKE. 61. PL/SQL supports DML (Insert, Update, Delete) and Transaction control commands of SQL (Commu, Rollback, Saysposnt) 62 Select statements within PL/SQL block must retum one and only one row A query that retums more than one row (TOO_MANY_ROWS) or no row (NO_DATA_FOUND) generates an error, 63. PLISQL does not return an error if a DML statement doet not affect any rows in the undertying table, however ifa SELECT statement does not remeve any’ rows PL/SQL retums an exception. SOUS or AES ee ™ “mr eH 6S, The PLISQL program opens a cursor, processes rows retumed by a query and then closes the cursor, ‘The cursce makes the cument ponition isthe Active set 66. Declare variables before the cursor declaration 67. Uf the query returns mo rows, no exception i rated. 63. You cannot reference cursos attibutes directly in a SQL statement (69. Before the firs fetch *sNOTFOUND evaluates to Null So if Fetch never executes successfuthy, the ‘Loop is never exited. that is because the EXIT WHEN statement. executes only if its WHEN aes Gi Take: see Oi Bing EXIT Semen” EXIT: WHEN senp_sussoxtsOTEOUND or 3 Null 70, When the same cursor is eferenced repeatedly we can pass parameters to the curser. We can also 72. Exception cannot appear in assignment statements ce SQL statements 73, You cannot wee SQLCODE and SQLERRM dinectly ana SQL statement. Instead, you must assign their values to local vanables, then uve dhe variables so the SQL statement, 2¥, FLIDYL Goes not axrectty support YLUL statements such as LxeAte, Alter, Lop tapie, 60. PL’SQL does not directly support DCL statements such as GRANT and REVOKE. 61. PLISQL supports DML (Insert, Update, Delete) and Traassction control commands of SQL (Commit, Rollback. Savepotst) 62. Select statements within PL/SQL block must return one and only one row. A query that returns more than one row (TOO_MANY_ROWS) or no row (NO_DATA_FOUND) generates an error 63. PLISQL does not renum an error if DML statement does not affect any rows in the undertying table, however ifa SELECT statement does not retrieve any rows PL/SQL rerams an exception. 64. SQLSMISOPEN always evaluates to FALSE because PL/SQL closes the implicit cursort ammeduately after Oey are executed. ‘The PL/SQL program opens a cursor, processes rows returned by a query’ andthen closes the cursor The cursor makes the cureat position i the Active set (66, Declare vanables before the cursor: 67. If the query retamsino rows, no exception is raised. 68. You cannot reference cunt attributes directty in a SQL statement. 69, Before the first fetch "eS ever executes successfully, the ‘Loop is wever gxited, that executes only af ty WHEN eatin A wee Tae sae, Mi te faery EIT: Heme EAT) ‘WHEN samp_cursor’sNOTEOUND or 8 70, When the same curvor is referenced repeatedly we can pass parameters to the cursor, We-can alto use cursor foe boop wath 71. A block always terminates when PL/SQL raises 28 exception 72. Exception cannot appear in assignment statements o¢ SQL statements. 73. You cannct wie SQLCODE and SQLERRM directly ava SQL statement. Instead, you must assign their values to local variables, then use the variables i the SQL statement, 74. The keyword DECLARE that is used to indicate the starting of the declaration section in anonymous blocks isnot used with the subprograms (Procedures er functicas). 75, There must be at least one statement existing inthe executable section, there must be atleast A. stxement 6 176, You cannot reference host or bind variables inthe PLSQL block ofa stored Procedure 77, You cannot restrict the size ofthe data type in the parameters ofthe 73. You must declare the suborogram in the declaration section of the block and must be the last item 71, Ablockalways terminates when PL/SQL raises an exception 72 Excepuon cannot appear mi assignment statements or SQL statements 73. You cannot ust SQLCODE and SQLERRM directly ma SQL statement. Instead, you must astign ‘their values to local variables, then use the variables an the SQL statement, 74. Thelkeyword DECLARE that is used to indicate the starting of the declaration section in anorymous blocks 1s:mot used with the subprograms (Procedures or functions) ‘75, There must be at least coe statement existing im the executable section, there must be aticast A ‘NULL statement that 15 considered. an executable statement, 76. You cannot reference host or bind variables in the PL/SQL block of a stored Procedure. 77, You cannot restrict the size of the data type in the parameters of the subprograms. 78. You must declare the subprogram m the declarahoa section of the block and must be the last stem, ‘after all the other program items. For example: A variable declared after the end of the subpeopram, ‘before the begin of the procedure, will cause the compilavon error. ‘79. A Function must have a Retum Clause in the Header and at least one Return Statement m the ‘executable section. 0. eum dan npe mn function éecaranoe must nt mchae ase specification 81. You cannct reference how of a stored Function. 82. Although multiple Retom ‘within an IF statement) only one Retam statement is executed. 33. It isa good programming practice to assign a return value to a variable and use a single rerum ‘Statement im the executable section of the code There can be a retum statement in the exception ‘Section of the program also. $4. A Function may accept ont of many parameter, but must return a sangle value 85. Although the three parameters modes (IN, OUT, INOUT) can be used with any subprogram, avoid (Using the OUT and INOUT modes wi Functions 86. Anywhere a built-in funcuoa can be placed, a user-defined function can be placed as well 87. Only stored functions are callable from SQL statements. Stored Procedures cannot be called. 88. Functions that are callable from SQL expressions cannot contain OUT and INOUT parameters, ‘Other fonctions can contain parameters iit theve modes but itis not recommended. 89, «A Procedure containing one OUT Parameter can rewnitten 35a fiction containing a RETURN Statement 90. Package cannot be invoked, parameterized or nested. 91. Package Specification and Body are stored sevarately in the database but mibst have the same name. 89. +A Procedure containing one OUT Parameter can rewriten as a function containing a. RETURN ‘Statement. 7 Parkage cannot be invoked, parameterized or Fon St ine rps ‘but must have the same name. 2 Define the Package Specification before www.thundershare.net 93. A Package Specification en exist without a package Body, bot package Baty cannot exist without ‘a package Specification. 14. nis gle commen in i package body to seal piv vara nd bprogrcs denn ft sand the public subprograms defined 95, Ifa Specification declares aly Ope cota, Variables, exceptions and call package body is unnecessary. Tower the Bd aml rel alien declared the package specificabon. 96, Changes fo the pactape specication equ recompilation of each referencing sbpropam. So packaged 98. Most built aa functions are overloaded. For ex: TO_CHAR function of standard package. 99. PL/SQL does not allow forward references, you must declare an identifier before using it. Therefore, ‘a program must be declared before calling it 109, ‘The excessive ive of Triggers can result in complex inter-dependencies, which may be difficult to maintain in large anolications. Only use Triegers when necessary and beware of 95x Palo pti om xk ea cee Dylan ug Day cm core o We com me uchge ty pe ale nd gpa dtd ‘and the publbe subprograms defined 05, fa Spas techs ony tps, cocmacs ashe, costs sot call pecan, he satan lyk ecany terre te eae Deen package specification 97. Only local or packaged subprograrss can be overloaded. You cannot overioad stand-alone. 9%. Most built-2n functions are overloaded. For ex: TO_CHAR fuschon of standard package. 99. PL/SQL does not allow forward references; you must déclare an identifier before using i. Therefore, ‘1 program must be dectared before caing t. 100, The excessive ure of Triggers can reeult in complex inter-dependencies, which may be difficult to maintaia ia large applications, Only use Triggers when necessary and beware of recurs and cascading effects 101 ‘If the logic forthe Trigger is very lengthy, create stored procedures with the logic an invoke them im the Trigger body using CALL statement. There is 90 semicolon at the end of call tere. 1O2_——_‘Nowe that database triggers fre for every user each time the event occurs for wich the Trigger is created ‘The size of a Trigger cannot be more 22) et raxange oprancana oan cam wRaouL a PaSaAgE Bow, Tuts PaCRARE OUUy GENIE FANN MUL a 34, Iti quite common in the package body to see all private variables and subprograms defined frst ‘iad the publae subprograms defised last 95, a Specitication declares only types, constants, variables, exceptions and call specifications, the ‘package body is unnecessary. However, the body can still be used to initialize items declared im the package specification 9, Changes to the package specification requires recompilation of each referencing subprogram. So place few construct as possible ina package specification. 97, Only local or packaged subprograms can be overloaded. You cannot overload stand-alone. 98. Most buit-s fictions are overloaded. For ex: TO_CHAR function of standard package 99. PL/SQL does not allow forward references; you must declare an identifier before using it. Therefore, 4 program mut be declared before calling it 100. ‘The excessive use of Triggers can result in complex inter-dependencies, which may be ifficutt to mamfain in Large applications. Only use Triggers when necessary and beware of 101 ‘Uf the logic forthe Trigger is very lengthy, create stored procedures with the logic and ao RGR RSTARE HE nese te tal 102. ‘Note that database triggers fre for every user each time the event occurs for whieh the ‘Trigger is created. 103. ‘The size of a Trigger cannot be more than 32K. 108. ‘Using cotta names along with the Update clause in the Trigger improves performance, ‘because the Trigger fires only when the particular column is updated and thas avoids unintended. 195. ‘You can combine several Triggering events into one by taking advantage of a special ‘conditional predicates INSERTING, UPDATING, DELETING with the Trigger body. 106, ‘The OLD and NEW quilifiers are available oaly in ROW Taggers and prefix these ‘qualifiers wits a colon () im every SQL and PL'SQL statement. 107. There is mo-colon () prefix ifthe qualifiers are referenced in the WHEN restricting ROW ‘Trigger can decrease the performance if you do alot of updates on larger tables 108. ‘When you specify ON SCHEMA, the Trigger fires for the specific user, if you specify ON DATABASE, the Trigges fires for al users. 109. A Tablets not considered Mutation for statement Triezers. snigger s createa 103. ‘The size of a Trigger cannot be more than 32K. 104 ‘Using coluran names along with the Update clause in the Trigger improves performance, ‘because the Trigger fires only when the particular column is updated and thes avoids umiotended firng when anyother column tt updated. 105. ‘You can combane sev perce Tema ae ts oe by eg nbemene ef pclt ‘conditional predicates INSERTING, UPDATING, DELETING wrth the Trigger 106. Tee OLD sn NEW query ne aviaie ony tx ROW Taggers nal pref tee (qualifiers witha colon () im every SQL and PL’SQL statement. 107, ‘There is no colon () prefix the qualifiers are referenced in the WHEN restricting ROW Tiger an deren the perforanace soe coat of wes a rer nes. 108, Vien you specify ON SCHEMA, the Triggesfices forthe specific uses, if you specify ON NOATABASE oe Whaes el iedienes 1% ‘A Table ts not considered Mueatin for statement Triggers Ho. ‘Starements in the Trigger Body operate under the privilege ofthe Trigger owner, not the ‘Trigger Mn ‘Uf the Package body changes and the Package specification does not changes, the stand mn. the package referencing a package coustruct i raked eps mB ‘fa Stand-alone procedure referenced within the package changes, the entire package body ‘is invalidated, but the package specification remains valad. Therefore, tis reccenmended that you. ‘bring the procedure into the package. 114, ‘Dynamic SQL sopporteall the SQL data types but does not supports PL’SQL specitic types ‘except PLSQL record. 1S, ‘You can use the INTO clause for a single-row query, but you must use OPEN-FOR, FETCH and CLOSE for a ulti row query. 116. The oracle 9: server performs implicit conversion between CLOB and VARCHAR? datatzpcs. The other implicit conversions between LOB's are not possible. Foe ex: ifthe user creates a table T wrth a CLOB column and 2 table S with a BLOB column, the data is not duxectly transferable berween these nwo columes, 117, Biary Files (BFILE’s) can be accessed only in read-only mode from an oracle server. 100+ SQL and PL/SQL Tips and Tricks ‘Zero is a number and a Space is a charactek. ‘Character strings and date values are enclosed in single quotation masks. (Character values are case sensitive and date values are format sensitive ‘The defult date format is DD-MON-RR. Oracle database stores date in a format Century, year, month, day, hours, minutes and seconds, ‘An Alias cannot be used in the WHERE clause. The sd sie sere es Sel Ss: 5 6. 7, 8 9. The IN condition ean be used with any data type 10. A NULL value cannot be equal (=) or unequal to any vale 11. NULL valves are displayed last for ascending sequences and first for descending 12. Column Alias can be used in the ORDER BY clause. 13. Syadate is & funetion that does not contain any argument but return current database server date and time: 14, Database stores dates as Numbers, so arithmetic operators such as addition and subtraction can be performed on dates, 15_ All Group Functions ignores null values, To substitutes a value for mull values, use the NVL. NVL2, or COALESCE functions. 16, The oracle server implicitly sorts the result set in ascending order when sing a Group By clause. To override this default ordering. DESC can be used in an Order By, clause. 6 Theasmball= and ‘also represents 0 not equal to-condision. 7. Values specified with the BETWEEN condition are inclusive 8. The IN condition is also called membership condition. 9. The IN condition can be used with any data type. 10. A NULL value cannot be equal (=) or unequal to any value. 11, NULL values are displayed last for ascending sequences and first for descending 12. Column Alias can be used in the ORDER BY clause. 13. Sysdate is a function that does not contain any argument but return current databace server date and time. 14. Database stores dates as Numbers, so arithmetic operators such as addition and subtraction can be performed on dates. 15, All Group Functions ignores null values, To substitutes a value for aull values, use the NVL, NVL2, or COALESCE functions 16. The oracle server implicitly sorts the result set in ascending order when using a Group By clause. To override thes fant Ger RENS FRED? eed in am Order By clause, . . 17. MIN and MAX functions can be used for any data type 18. AVG, SUM, VARIANCE, and STDDEV functions can be used only wath Numenc data types. 19. You cannot use a column alias in the GROUP BY clause 20. All columns in the SELECT list that are not in group functions must be in the GROUP BY clause 21, The GROUP BY column does not have to be in the SELECT list 22. To restrict groups use HAVING clause not WHERE clase. 23. Don’t use Group functions in the Where clause. ‘24, Using the Table prefixes (alias) with the column names improves Performance, ‘because if tells the oracle server exactly where to find the columns. It also helps to. keep SQL code smaller, therefore using less memory’ 25. A condition mvolving an Outer Jom cannot use IN and OR operator. 15. ‘Ail Group Fooctions ignores ool values To substitutes.a value for mull values, use the NVL, NVL2, ar COALESCE functions. 16. The oracle server implicitly sorts the result set in ascending order when using a Group By clause. To override this default ordering. DESC can be used in an Order By clause, 17. MIN and MAX functions can be used for any data type 18. AVG, SUM, VARIANCE, and STDDEV functions can be used only with Numenc data types 19. You cannot use a column alias in the GROUP BY clause. 20. All columns an the SELECT lst that are not m group functions must be an the GROUP BY clause. 21. The GROUP BY column does not have to be in the SELECT list. 22. To restrict groups use HAVING clause not WHERE clause. 23. Don't use Group functions in the Where clause, a Ung te Tae eta rapa einer‘ Peomane, ‘because it tells the oracle server c columns. It also helps to keep SQL code smaller, therefore using less memory. 25. A condition involving an Outer Join cannot use IN and OR operator. 26. The statement with the values clause adds only one row at a time to a table. 27. You can use-a subquery in place of the table-name in to INTO clause of the INSERT statement 28, When creating a table by using a subquery, the integrity rules are not passed of: to the new table, only the column data type definitions are passed. 29. When you add a new column in a table using ALTER command, than the new column become the last column an that table. 30. During modifying a column You can increase the width of a numeric or character column. 31. During modifying a column. You can decrease the width of a column only if the column cantans only nll values oe if the table has ne roe 26. The statement with the values clause adds only one row at a time to a table 27. You can use a subquesy in place of the table name in to INTO clause of the INSERT statement 28, When creating a table by using a subguery. the integrity rules are not passed on to the new table, only the column data type definitions are passed 29. When you add a new columin in a table using ALTER command, than the new column ‘become the last column m that table. 30, During modifying a column You can inerease the width of a aumerte or character ‘column. 31. During modifying a column You can decrease the width of a columa only if the column contains only ull values or if the table has no rows www.thundershare.net 32. During modifying a column You can change the data type only if the column contains ull values 33. You can convert a CHAR column to the VARCHAR? data type or convert a VARCHAR? column to the CHAR data type only if the column contains null values of if you do.not change the size

You might also like