Monday, January 27, 2020
The Women In Love Essay
The Women In Love Essay Women in Love is a novel about two young ladies, the Brangwen sisters, Urusula and Gudrun and how they fall in love and lead two completely different relationships with the men they meet, Rupert Birkin and Gerald Crich, with who they gradually fall in love. Birkin, a school inspector, visits Ursula who teaches at the school however Hermione, the woman previously involved with Birkin, intrudes on their conversation and invites Ursula and Gudrun to stay with her in Breadalby. Ursula and Gudrun travel to Breadalby to stay with Hermione where Gerald officially meets the two. He saw them again, while they were at home waiting for the train to pass. This sets an awful impression of Gerald to the sisters as he was torturing a horse, training her to withstand the fear. The Brangwen sisters then see Gerald again, whilst sketching along side Wiley Water. He was with Hermione who caused commotion between Gudrun and Gerald after dropping her sketchbook in the water. In the meantime, Ursula had wandered off towards the hill where she met Birkin sawing and hammering away. This was the first sign of a relationship between the two and he eventually sent a note to invite the sisters to tea. Feeling desire for Birkin to speak only to her, she didnt tell Gudrun about the invite where they discuss the concepts of love and their feelings. The couple met again at Mr. Crichs annual water-party on the lake. Gerald organises a small boat for Gudrun and Ursula who row to a little stream. After hours on end, the men arrive in worry. The four begin to row back to the estate but Geralds sister, Diana, drowns causing grief for the Crichs. Gudrun then becomes the teacher of Geralds youngest sister, Winifred. There relationship was a tight bond and soon she moves into a studio which was built for the two girls. After many thought and consideration, Birkin visits the Brangwens to ask for Ursulas hand in marriage however Birkin left without an answer. Enraged, he walks to Shortlands where he finds Gerald. Ursula then meets with Hermione who belittles Birkin and encourages Ursula not to marry him. Birkin then buys Ursula three rings which leads her to agreeing to marriage. Mr. Crich sadly then passes away and after the funeral, in devastation Gerald spends the night with Gudrun. Gerald then thinks about marrying Gudrun and he suggests for the four to travel to the Tyrol although Birkin and Ursula left early to Verona. Gerald is infuriated by Gudruns verbal abuse and her refusal of his manhood as well as Loerke who Gudrun begins a friendship with. On the slopes, Gerald strangles Gudrun yet let go when Loerke called for him. Gerald continued up the slope but he slipped and fell and immediately went to sleep. His body was returned to England to be buried, together with Ursula and Birkin. Gudrun went to Dresden to visit Loerke. The impact of Geralds death on Birkin was inevitable, he loved him just as much as he loved Urusla however Ursula could not understand this. Narrative Style This novel is written in third person singular with an omniscient style. It pleased Ursula, what he said, pleased her very much. She herself knew too well the actuality of humanity, its hideous actually. The pronouns he and she are frequently used and characters are continuously addressed by their names. Character Analysis Ursula: is an independent, strong-willed lady who doesnt enjoy being told what to do. She likes to make her own decisions, no matter what the situation. This is shown through the conversation held between, herself, her father and Birkin when he proposes to her; You both want me to force me into something That is an illusion of your own. She also needs certainty to make those decisions which is shown through her constant questioning of if Birkin loves her. She is reliable for Birkin as she devotes her everything to him however she seems to misunderstand the importance of a relationship between the men and seems she is jealous that Birkin doesnt only need her. Gudrun: is a very kind and compassionate woman as she takes the time and effort to sit with Winifred and paint. Her loving character is shown when she feels uneasy about telling Winifred that her dad will die when asked what she thinks. She isnt a trustworthy person as she leaves Gerald for Loerke in the Alps and feels what Gerald and she had, was over although Gerald didnt feel this way. Birkin: has an aspect of a true gentleman. This is shown through his love and devotion to Ursula because he states that he doesnt want to serve him; I who am at the beck and call of the woman, than she at mine. His love for Ursula and Gerald also shows that he can maintain love with romance and love with friendship; eternal union with a man too: another kind of love. Gerald: is a determined man as he has hope that his sister was still alive when he tries to save her and he never gives up. These experiences made Gerald the strong, determined man he was, as he had suffered of loss of those close to him. However he is not independent as when his father passes away he finds himself at the graveyard then walks to Gudruns house seeking comfort and affection. Gerald is also a proud character as he is proud of his estate that his father owns and doesnt let the past affect his present. Language Diction Women in Love is a very descriptive novel that uses both short and long sentences. The language is highly developed and long sentences are used to describe feelings and objects, for example; And Gerald, watching, saw the amazing attractive goodliness of his eyes, a young, spontaneous goodness that attracted the other man infinitely, yet filled him with bitter chagrin, because he mistrusted it so much. Short sentences are used more often during dialogue such as; I see, and I must remember another time. In this novel the author also uses similes for instance; The mare rebounded like a drop of water from hot iron and Yet he seemed as calm as a ray of cold sunshine. There are also French and German phrases during dialogue for example; Ist er auch ein Wunder? and Quest ce quun chancelier?. Imagery The imagery is evident throughout the novel because all stimuli are aroused. Tactile imagery is evident when Ursula and Birkin have admitted their love for one another; She cleaved to him, and he could feel his blood changing like quicksilver. One can imagine how faster his blood was pumping now that Ursula lay closer towards him. Taste and sense of smell are linked with the description of the meal provided; venison pasty, a large broad-faced cut ham, eggs and cresses. Visual imagery is foreseen throughout the novel when the statuette is explain; it was a woman, with hair dressed high, like a melon-shaped dome à ¢Ã¢â ¬Ã ¦ with such protuberant buttocks, so weighty and unexpected below her slim long loins. Auditory imagery is evident when Geralds voice startles Gudrun for example; The timbre of his voice, like something vibrating at a high pitch, unnerved Gudrun. Themes Marriage is a theme shown through Ursula and Gudrun when it is first mentioned at the beginning of the novel. This theme is revealed throughout the novel as their relationships continue to build which gradually leads to a proposal by Birkin to Ursula. A theme of religion is also apparent throughout the novel by Mr. Crich as he is related to God often and speaks of being a Christian. Another theme present is individual versus society as Ursula, Gudrun, Birkin and Gerald are often deeply concerned with the questions of society and the relationships between men and women. This theme is shown through Birkin and Ursulas conversation how one must devote themselves to one another as Birkin believes love can reach further and past heaven. Setting This novel is set in England, this is evident because of the places mentioned such as London, Oxford, Beldover and Piccadilly Circus. It is also represented throughout the relation to the currency for example; Three-hapence, pennies and Hundreds of pounds. The setting is also shown through certain objects such as The Daily Telegraph, a popular newspaper in England as well as lawn rather than garden. Genre The genre is romance as love is such a deep and dominant theme throughout the novel. The genre starts with the when Gudrun and Ursula Brangwen discuss their feelings towards marriage. It is encouraged throughout the novel by Gudrun and Gerald falling in love and Ursula and Birkin getting married. It is also shown through Birkin and Geralds friendship as Birkin finds their friendship the perfect relationship with a man. Aspects I liked I enjoyed the fact that Mr. Crich had such a strong will to stay alive, he made time and effort for the ones he loved dearly such as his daughter Winifred. He also said to Winifred that he was better whenever he asked, meanwhile they both knew the truth. However I didnt emjoy the fact that Hermione belittled Birkin whilst talking to Ursula, she encourages Ursula not to marry Birkin because of her jealousy over their relationship. Hermoine wanted with Birkin what Urusla has and she belittles Birkin to alter Ursulas feelings but Ursula ignores Hermoines comments and continues to feel the love she has for Birkin. Recommendations I would recommend this novel to one who enjoys an emotional relationship which encounters tension commonly because of love and the meaning it implies. I would also recommend this novel to one who shares a relationship with God as one of the characters shares a strong relationship with God; He wanted to be a pure Christian, one and equal with all men. He even wanted to give away all he had, to the poor. Throughout the novel, God is often referred to which is why I would recommend this novel to a Christian. I would recommend this novel to a person who enjoys strong willed characters who are strained with their sensitivity.
Sunday, January 19, 2020
Between 1820 and 1860 there were a few fundamental differences between the economies of the North and South Essay
?Between 1820 and 1860 there were a few fundamental differences between the economies of the North and South. How far do you agree? Between 1820 and 1860 there were problems in America that resulted in the civil war in 1861, the economy affected the North and South during the civil war, and some major differences helped win the civil war. However this does not mean that the economy had many fundamental differences. For example the methods of earning money were different, but overall both earned roughly the same amount of money. Firstly, the main difference was that the North relied much more on money from industry and manufacturing, as they had more connections with foreign countries, and more factories were built. In the North in 1860 there were 74,000 factories producing two thirds, of goods for America. Whereas in the South there were only 2 major factors: Textiles factory in South Carolina and an Iron works in Virginia set up in 1840. Although they had fewer factories, the Iron works was vital, as it supplied the North with weaponry during the Civil war. In 1850 the South only produced 10% of the nations manufactured output. However the South did lack the industrialisation because their agricultural methods were so effective they had no need for change. The South was also very traditional and disliked change, whereas seven out of eight immigrants had chosen to settle in the North, and they had seen new ideas in other places in Europe so were welcome to change. This is shown by the Southââ¬â¢s labour force being reduced from 82% to 81% over 60 years, on the other hand, the Northââ¬â¢s labour force was reduced from 68% to 40% over the 60 years. This is however not a reflection on the North rapidly reducing agriculturally, because they still relied on agriculture, and a lot of the North was still rural. Around the urban areas, the population was increasing as towns and cities were developing swiftly. As the North had smaller but still prosperous farmers known as yeomen, they did not earn as much money through agriculture, because they did not have many or any slaves at all, so they could not produce the high quantities that the south did. Farmers that had lots of land were called plantation owners; there were many more plantations in the south, and when the cotton gin was created in 1793, there was a boom in cotton, and the benefit of having slaves increased. This made Southern plantation owners invest their capital in the Slaves, because they produced so much cotton, which was very lucrative. 55% of slaves worked in cotton which shows how much money was made out of it. The South needed to transport their goods to the North so that it could be transported abroad, but there was a lack of transport in South, as they only had 35% of the train tracks, which affected them in the Civil war. This meant it was fairly expensive to transport the cotton, but they still received a good amount of money if they lived near a train track. When the cotton arrived in the North the Lowell factory system meant the manufacturing of it was very cheap, which meant the North earnt a large margin on it. Although the danger of the South investing all their money in Slaves was that when slavery got banned, they lost a lot of money, which was partly why they were so keen to keep slavery. However only one quarter of the population owned a slave, as they were expensive (in 1860 they were $1800 which was double the price in 1820). The Northââ¬â¢s economy was based on free labour whereas the Southââ¬â¢s was based on slave labour, which meant that the Northââ¬â¢s economy was more stimulated by the presence of workers with money who could buy products, which would make money for the company, which in turn would increase wages or hire more workers. The Southââ¬â¢s economy was largely devoid of this benefit. Essentially, the economy in the South was weaker and only based on a few important exports (cotton, tobacco, and sugar). This made the South less diversified, as they focused their sales on cotton. Another difference is tariffs; in 1828 congress passes a controversial high protective tax. This majorly benefitted the North as they were the main distributors. However the South were very worried about this because they believed that if they stopped buying the expensive foreign goods, then foreign countries would stop buying their goods, as they would have tax on them too. This affected the economy until the tax was promised to be reduced after the law in 1833. In contrast the North and South didnââ¬â¢t have many fundamental differences. They both created a lot of money, and were not lacking at all, the only difference was the method in which was used to make the money. The economic diversification was similar too, as 10% of Northerners owned 68% of the wealth, and the wealth was dominated by the plantation owners, called oligarchies, as there were few free-soilers. 12% of the plantation owners owned half the slaves. This shows that there were few farmers, but the big plantations owned many slaves. Even though the North seems to be more industrial, the South also made efforts to modernise industrially, but they just lacked because of the closed opinions of the southerners. Also not many people in the North and the South owned slaves, it was more of a rare thing, and the main owners, owned a large amount of slaves. However there was a larger need for slaves in the South, because there was cheap labour force from Europe settling in the North which meant slaves were more expensive so were not deemed as important. Overall I think there were many differences between the North and South between 1820 and 1860. Some affected the outcome of the Civil war such as the transport boom, and the industrialisation in the North, but a fundamental point is that numerically they have equal amounts of income; there were just different methods to earning the money. However the differences were major; the amount of industrialisation, and amount of agriculture, the manufactured output, and the need for slaves, was all very different for the North and South. The main similarity was the economic diversification.
Friday, January 10, 2020
Sql Study Matetial
Oracle/SQL Tutorial1 Michael Gertz Database and Information Systems Group Department of Computer Science University of California, Davis [emailà protected] ucdavis. edu http://www. db. cs. ucdavis. edu This Oracle/SQL tutorial provides a detailed introduction to the SQL query language and the Oracle Relational Database Management System. Further information about Oracle and SQL can be found on the web site www. db. cs. ucdavis. edu/dbs. Comments, corrections, or additions to these notes are welcome. Many thanks to Christina Chung for comments on the previous version. Recommended LiteratureGeorge Koch and Kevin Loney: Oracle8 The Complete Reference (The Single Most Comprehensive Sourcebook for Oracle Server, Includes CD with electronic version of the book), 1299 pages, McGraw-Hill/Osborne, 1997. Michael Abbey and Michael Corey: Oracle8 : A Beginnerââ¬â¢s Guide [A Thorough Introduction for First-time Users], 767 pages, McGraw-Hill/Osborne, 1997. Steven Feuerstein, Bill Pribyl, Deb by Russell: Oracle PL/SQL Programming (2nd Edition), Oââ¬â¢Reilly & Associates, 1028 pages, 1997. C. J. Date and Hugh Darwen: A Guide to the SQL Standard (4th Edition), Addison-Wesley, 1997. Jim Melton and Alan R.Simon: Understanding the New SQL: A Complete Guide (2nd Edition, Dec 2000), The Morgan Kaufmann Series in Data Management Systems, 2000. 1 revised Version 1. 01, January 2000, Michael Gertz, Copyright 2000. Contents 1. SQL ââ¬â Structured Query Language 1. 1. Tables 1. 2. Queries (Part I) 1. 3. Data De? nition in SQL 1. 4. Data Modi? cations in SQL 1. 5. Queries (Part II) 1. 6. Views 1 3 6 9 11 19 2. SQL*Plus (Minimal User Guide, Editor Commands, Help System) 20 3. Oracle Data Dictionary 23 4. Application Programming 4. 1. PL/SQL 4. 1. 1 Introduction 4. 1. 2 Structure of PL/SQL Blocks 4. 1. Declarations 4. 1. 4 Language Elements 4. 1. 5 Exception Handling 4. 1. 6 Procedures and Functions 4. 1. 7 Packages 4. 1. 8 Programming in PL/SQL 4. 2. Embedded SQL and Pro*C 26 2 7 27 28 32 34 36 38 39 5. Integrity Constraints and Triggers 5. 1. Integrity Constraints 5. 1. 1 Check Constraints 5. 1. 2 Foreign Key Constraints 5. 1. 3 More About Column- and Table Constraints 5. 2. Triggers 5. 2. 1 Overview 5. 2. 2 Structure of Triggers 5. 2. 3 Example Triggers 5. 2. 4 Programming Triggers 6. System Architecture 6. 1. Storage Management and Processes 6. 2. Logical Database Structures 6. 3.Physical Database Structures 6. 4. Steps in Processing an SQL Statement 6. 5. Creating Database Objects 46 47 49 50 50 53 55 58 60 61 63 63 1 SQL ââ¬â Structured Query Language 1. 1 Tables In relational database systems (DBS) data are represented using tables (relations ). A query issued against the DBS also results in a table. A table has the following structure: Column 1 Column 2 . . . Column n â⬠¦ â⬠¦ â⬠¦ â⬠¦ A table is uniquely identi? ed by its name and consists of rows that contain the stored information, each row containing exactly one tuple (or recor d ). A table can have one or more columns.A column is made up of a column name and a data type, and it describes an attribute of the tuples. The structure of a table, also called relation schema, thus is de? ned by its attributes. The type of information to be stored in a table is de? ned by the data types of the attributes at table creation time. SQL uses the terms table, row, and column for relation, tuple, and attribute, respectively. In this tutorial we will use the terms interchangeably. A table can have up to 254 columns which may have di? erent or same data types and sets of values (domains), respectively.Possible domains are alphanumeric data (strings), numbers and date formats. Oracle o? ers the following basic data types: â⬠¢ char(n): Fixed-length character data (string), n characters long. The maximum size for n is 255 bytes (2000 in Oracle8). Note that a string of type char is always padded on right with blanks to full length of n. ( can be memory consuming). Exampl e: char(40) â⬠¢ varchar2(n): Variable-length character string. The maximum size for n is 2000 (4000 in Oracle8). Only the bytes used for a string require storage. Example: varchar2(80) â⬠¢ number(o, d): Numeric data type for integers and reals. = overall number of digits, d = number of digits to the right of the decimal point. Maximum values: o =38, d= ? 84 to +127. Examples: number(8), number(5,2) Note that, e. g. , number(5,2) cannot contain anything larger than 999. 99 without resulting in an error. Data types derived from number are int[eger], dec[imal], smallint and real. â⬠¢ date: Date data type for storing date and time. The default format for a date is: DD-MMM-YY. Examples : ââ¬â¢13-OCT-94ââ¬â¢, ââ¬â¢07-JAN-98ââ¬â¢ 1 â⬠¢ long: Character data up to a length of 2GB. Only one long column is allowed per table. Note: In Oracle-SQL there is no data type boolean.It can, however, be simulated by using either char(1) or number(1). As long as no constraint restricts the possible values of an attribute, it may have the special value null (for unknown). This value is di? erent from the number 0, and it is also di? erent from the empty string ââ¬â¢Ã¢â¬â¢. Further properties of tables are: â⬠¢ the order in which tuples appear in a table is not relevant (unless a query requires an explicit sorting). â⬠¢ a table has no duplicate tuples (depending on the query, however, duplicate tuples can appear in the query result). A database schema is a set of relation schemas.The extension of a database schema at database run-time is called a database instance or database, for short. 1. 1. 1 Example Database In the following discussions and examples we use an example database to manage information about employees, departments and salary scales. The corresponding tables can be created under the UNIX shell using the command demobld. The tables can be dropped by issuing the command demodrop under the UNIX shell. The table EMP is used to store information about employees: EMPNO ENAME JOB MGR HIREDATE SAL DEPTNO 7369 SMITH CLERK 7902 17-DEC-80 800 20 7499 ALLEN SALESMAN 7698 20-FEB-81 1600 30 7521WARD SALESMAN 7698 22-FEB-81 1250 30 â⬠¦Ã¢â¬ ¦Ã¢â¬ ¦Ã¢â¬ ¦Ã¢â¬ ¦Ã¢â¬ ¦Ã¢â¬ ¦Ã¢â¬ ¦Ã¢â¬ ¦Ã¢â¬ ¦Ã¢â¬ ¦Ã¢â¬ ¦Ã¢â¬ ¦Ã¢â¬ ¦Ã¢â¬ ¦Ã¢â¬ ¦Ã¢â¬ ¦Ã¢â¬ ¦Ã¢â¬ ¦.. 7698 BLAKE MANAGER 01-MAY-81 3850 30 7902 FORD ANALYST 7566 03-DEC-81 3000 10 For the attributes, the following data types are de? ned: EMPNO:number(4), ENAME:varchar2(30), JOB:char(10), MGR:number(4), HIREDATE:date, SAL:number(7,2), DEPTNO:number(2) Each row (tuple) from the table is interpreted as follows: an employee has a number, a name, a job title and a salary. Furthermore, for each employee the number of his/her manager, the date he/she was hired, and the number of the department where he/she is working are stored. 2The table DEPT stores information about departments (number, name, and location): DEPTNO 10 20 30 40 DNAME STORE RESEARCH SALES MARKETING L OC CHICAGO DALLAS NEW YORK BOSTON Finally, the table SALGRADE contains all information about the salary scales, more precisely, the maximum and minimum salary of each scale. GRADE 1 2 3 4 5 1. 2 LOSAL 700 1201 1401 2001 3001 HISAL 1200 1400 2000 3000 9999 Queries (Part I) In order to retrieve the information stored in the database, the SQL query language is used. In the following we restrict our attention to simple SQL queries and defer the discussion of more complex queries to Section 1. In SQL a query has the following (simpli? ed) form (components in brackets [ ] are optional): select [distinct] from [ where ] [ order by ] 1. 2. 1 Selecting Columns The columns to be selected from a table are speci? ed after the keyword select. This operation is also called projection. For example, the query select LOC, DEPTNO from DEPT; lists only the number and the location for each tuple from the relation DEPT. If all columns should be selected, the asterisk symbol ââ¬Å"? â⬠can be used to denote all attributes. The query select ? from EMP; retrieves all tuples with all columns from the table EMP.Instead of an attribute name, the select clause may also contain arithmetic expressions involving arithmetic operators etc. select ENAME, DEPTNO, SAL ? 1. 55 from EMP; 3 For the di? erent data types supported in Oracle, several operators and functions are provided: â⬠¢ for numbers: abs, cos, sin, exp, log, power, mod, sqrt, +, ? , ? , /, . . . â⬠¢ for strings: chr, concat(string1, string2), lower, upper, replace(string, search string, replacement string), translate, substr(string, m, n), length, to date, . . . â⬠¢ for the date data type: add month, month between, next day, to char, . . The usage of these operations is described in detail in the SQL*Plus help system (see also Section 2). Consider the query select DEPTNO from EMP; which retrieves the department number for each tuple. Typically, some numbers will appear more than only once in the query result, tha t is, duplicate result tuples are not automatically eliminated. Inserting the keyword distinct after the keyword select, however, forces the elimination of duplicates from the query result. It is also possible to specify a sorting order in which the result tuples of a query are displayed.For this the order by clause is used and which has one or more attributes listed in the select clause as parameter. desc speci? es a descending order and asc speci? es an ascending order (this is also the default order). For example, the query select ENAME, DEPTNO, HIREDATE from EMP; from EMP order by DEPTNO [asc], HIREDATE desc; displays the result in an ascending order by the attribute DEPTNO. If two tuples have the same attribute value for DEPTNO, the sorting criteria is a descending order by the attribute values of HIREDATE. For the above query, we would get the following output: ENAME DEPTNO HIREDATEFORD 10 03-DEC-81 SMITH 20 17-DEC-80 BLAKE 30 01-MAY-81 WARD 30 22-FEB-81 ALLEN 30 20-FEB-81 â⠬ ¦Ã¢â¬ ¦Ã¢â¬ ¦Ã¢â¬ ¦Ã¢â¬ ¦Ã¢â¬ ¦Ã¢â¬ ¦Ã¢â¬ ¦Ã¢â¬ ¦ 1. 2. 2 Selection of Tuples Up to now we have only focused on selecting (some) attributes of all tuples from a table. If one is interested in tuples that satisfy certain conditions, the where clause is used. In a where clause simple conditions based on comparison operators can be combined using the logical connectives and, or, and not to form complex conditions. Conditions may also include pattern matching operations and even subqueries (Section 1. 5). 4 Example:List the job title and the salary of those employees whose manager has the number 7698 or 7566 and who earn more than 1500: select JOB, SAL from EMP where (MGR = 7698 or MGR = 7566) and SAL > 1500; For all data types, the comparison operators =, ! = or , , are allowed in the conditions of a where clause. Further comparison operators are: â⬠¢ Set Conditions: [not] in () Example: select ? from DEPT where DEPTNO in (20,30); â⬠¢ Null value: is [not] null, i. e. , for a tuple to be selected there must (not) exist a de? ned value for this column. Example: select ? from EMP where MGR is not null; Note: the operations = null and ! null are not de? ned! â⬠¢ Domain conditions: [not] between and Example: â⬠¢ select EMPNO, ENAME, SAL from EMP where SAL between 1500 and 2500; â⬠¢ select ENAME from EMP where HIREDATE between ââ¬â¢02-APR-81ââ¬â¢ and ââ¬â¢08-SEP-81ââ¬â¢; 1. 2. 3 String Operations In order to compare an attribute with a string, it is required to surround the string by apostrophes, e. g. , where LOCATION = ââ¬â¢DALLASââ¬â¢. A powerful operator for pattern matching is the like operator. Together with this operator, two special characters are used: the percent sign % (also called wild card), and the underline , also called position marker.For example, if one is interested in all tuples of the table DEPT that contain two C in the name of the department, the condition would be where DNAME like ââ¬â¢%C%C%â⠬â¢. The percent sign means that any (sub)string is allowed there, even the empty string. In contrast, the underline stands for exactly one character. Thus the condition where DNAME like ââ¬â¢%C C%ââ¬â¢ would require that exactly one character appears between the two Cs. To test for inequality, the not clause is used. Further string operations are: â⬠¢ upper() takes a string and converts any letters in it to uppercase, e. g. DNAME = upper(DNAME) (The name of a department must consist only of upper case letters. ) â⬠¢ lower() converts any letter to lowercase, â⬠¢ initcap() converts the initial letter of every word in to uppercase. â⬠¢ length() returns the length of the string. â⬠¢ substr(, n [, m]) clips out a m character piece of , starting at position n. If m is not speci? ed, the end of the string is assumed. substr(ââ¬â¢DATABASE SYSTEMSââ¬â¢, 10, 7) returns the string ââ¬â¢SYSTEMSââ¬â¢. 5 1. 2. 4 Aggregate Functions Aggregate functions are statistical functions such as count, min, max etc. They are used to compute a single value from a set of attribute values of a column: count ax min sum avg Note: 1. 3 1. 3. 1 Counting Rows Example: How many tuples are stored in the relation EMP? select count(? ) from EMP; Example: How many di? erent job titles are stored in the relation EMP? select count(distinct JOB) from EMP; Maximum value for a column Minimum value for a column Example: List the minimum and maximum salary. select min(SAL), max(SAL) from EMP; Example: Compute the di? erence between the minimum and maximum salary. select max(SAL) ââ¬â min(SAL) from EMP; Computes the sum of values (only applicable to the data type number) Example: Sum of all salaries of employees working in the department 30. elect sum(SAL) from EMP where DEPTNO = 30; Computes average value for a column (only applicable to the data type number) avg, min and max ignore tuples that have a null value for the speci? ed attribute, but count considers null values. Data De? nition in SQL Creating Tables The SQL command for creating an empty table has the following form: create table ( [not null] [unique] [], â⬠¦Ã¢â¬ ¦Ã¢â¬ ¦ [not null] [unique] [], [] ); For each column, a name and a data type must be speci? ed and the column name must be unique within the table de? nition. Column de? nitions are separated by colons. There is no di? rence between names in lower case letters and names in upper case letters. In fact, the only place where upper and lower case letters matter are strings comparisons. A not null 6 constraint is directly speci? ed after the data type of the column and the constraint requires de? ned attribute values for that column, di? erent from null. The keyword unique speci? es that no two tuples can have the same attribute value for this column. Unless the condition not null is also speci? ed for this column, the attribute value null is allowed and two tuples having the attribute value null for this column do not violate the constraint.Example: The create table statement for our EMP table has the form create table EMP ( EMPNO number(4) not null, ENAME varchar2(30) not null, JOB varchar2(10), MGR number(4), HIREDATE date, SAL number(7,2), DEPTNO number(2) ); Remark: Except for the columns EMPNO and ENAME null values are allowed. 1. 3. 2 Constraints The de? nition of a table may include the speci? cation of integrity constraints. Basically two types of constraints are provided: column constraints are associated with a single column whereas table constraints are typically associated with more than one column.However, any column constraint can also be formulated as a table constraint. In this section we consider only very simple constraints. More complex constraints will be discussed in Section 5. 1. The speci? cation of a (simple) constraint has the following form: [constraint ] primary key | unique | not null A constraint can be named. It is advisable to name a constraint in order to get m ore meaningful information when this constraint is violated due to, e. g. , an insertion of a tuple that violates the constraint. If no name is speci? ed for the constraint, Oracle automatically generates a name of the pattern SYS C.The two most simple types of constraints have already been discussed: not null and unique. Probably the most important type of integrity constraints in a database are primary key constraints. A primary key constraint enables a unique identi? cation of each tuple in a table. Based on a primary key, the database system ensures that no duplicates appear in a table. For example, for our EMP table, the speci? cation create table EMP ( EMPNO number(4) constraint pk emp primary key, . . . ); 7 de? nes the attribute EMPNO as the primary key for the table. Each value for the attribute EMPNO thus must appear only once in the table EMP.A table, of course, may only have one primary key. Note that in contrast to a unique constraint, null values are not allowed. Examp le: We want to create a table called PROJECT to store information about projects. For each project, we want to store the number and the name of the project, the employee number of the projectââ¬â¢s manager, the budget and the number of persons working on the project, and the start date and end date of the project. Furthermore, we have the following conditions: ââ¬â a project is identi? ed by its project number, ââ¬â the name of a project must be unique, ââ¬â the manager and the budget must be de? ed. Table de? nition: create table PROJECT ( PNO number(3) constraint prj pk primary key, PNAME varchar2(60) unique, PMGR number(4) not null, PERSONS number(5), BUDGET number(8,2) not null, PSTART date, PEND date); A unique constraint can include more than one attribute. In this case the pattern unique(, . . . , ) is used. If it is required, for example, that no two projects have the same start and end date, we have to add the table constraint constraint no same dates unique( PEND, PSTART) This constraint has to be de? ned in the create table command after both columns PEND and PSTART have been de? ed. A primary key constraint that includes more than only one column can be speci? ed in an analogous way. Instead of a not null constraint it is sometimes useful to specify a default value for an attribute if no value is given, e. g. , when a tuple is inserted. For this, we use the default clause. Example : If no start date is given when inserting a tuple into the table PROJECT, the project start date should be set to January 1st, 1995: PSTART date default(ââ¬â¢01-JAN-95ââ¬â¢) Note: Unlike integrity constraints, it is not possible to specify a name for a default. 8 1. 3. 3 Checklist for Creating TablesThe following provides a small checklist for the issues that need to be considered before creating a table. â⬠¢ What are the attributes of the tuples to be stored? What are the data types of the attributes? Should varchar2 be used instead of char ? â⠬ ¢ Which columns build the primary key? â⬠¢ Which columns do (not) allow null values? Which columns do (not) allow duplicates ? â⬠¢ Are there default values for certain columns that allow null values ? 1. 4 Data Modi? cations in SQL After a table has been created using the create table command, tuples can be inserted into the table, or tuples can be deleted or modi? ed. 1. 4. 1Insertions The most simple way to insert a tuple into a table is to use the insert statement insert into [()] values (); For each of the listed columns, a corresponding (matching) value must be speci? ed. Thus an insertion does not necessarily have to follow the order of the attributes as speci? ed in the create table statement. If a column is omitted, the value null is inserted instead. If no column list is given, however, for each column as de? ned in the create table statement a value must be given. Examples: insert into PROJECT(PNO, PNAME, PERSONS, BUDGET, PSTART) values(313, ââ¬â¢DBSââ¬â¢, 4, 150000. 42, ââ¬â¢10-OCT-94ââ¬â¢); r insert into PROJECT values(313, ââ¬â¢DBSââ¬â¢, 7411, null, 150000. 42, ââ¬â¢10-OCT-94ââ¬â¢, null); If there are already some data in other tables, these data can be used for insertions into a new table. For this, we write a query whose result is a set of tuples to be inserted. Such an insert statement has the form insert into [()] Example: Suppose we have de? ned the following table: 9 create table OLDEMP ( ENO number(4) not null, HDATE date); We now can use the table EMP to insert tuples into this new relation: insert into OLDEMP (ENO, HDATE) select EMPNO, HIREDATE from EMP where HIREDATE < ââ¬â¢31-DEC-60ââ¬â¢; 1. 4. 2 UpdatesFor modifying attribute values of (some) tuples in a table, we use the update statement: update set = , . . . , = [where ]; An expression consists of either a constant (new value), an arithmetic or string operation, or an SQL query. Note that the new value to assign to must a the matching data typ e. An update statement without a where clause results in changing respective attributes of all tuples in the speci? ed table. Typically, however, only a (small) portion of the table requires an update. Examples: â⬠¢ The employee JONES is transfered to the department 20 as a manager and his salary is increased by 1000: pdate EMP set JOB = ââ¬â¢MANAGERââ¬â¢, DEPTNO = 20, SAL = SAL +1000 where ENAME = ââ¬â¢JONESââ¬â¢; â⬠¢ All employees working in the departments 10 and 30 get a 15% salary increase. update EMP set SAL = SAL ? 1. 15 where DEPTNO in (10,30); Analogous to the insert statement, other tables can be used to retrieve data that are used as new values. In such a case we have a instead of an . Example: All salesmen working in the department 20 get the same salary as the manager who has the lowest salary among all managers. update EMP set SAL = (select min(SAL) from EMP where JOB = ââ¬â¢MANAGERââ¬â¢) where JOB = ââ¬â¢SALESMANââ¬â¢ and DEPTNO = 20;Ex planation: The query retrieves the minimum salary of all managers. This value then is assigned to all salesmen working in department 20. 10 It is also possible to specify a query that retrieves more than only one value (but still only one tuple! ). In this case the set clause has the form set() = . It is important that the order of data types and values of the selected row exactly correspond to the list of columns in the set clause. 1. 4. 3 Deletions All or selected tuples can be deleted from a table using the delete command: delete from [where ]; If the where clause is omitted, all tuples are deleted from the table.An alternative command for deleting all tuples from a table is the truncate table command. However, in this case, the deletions cannot be undone (see subsequent Section 1. 4. 4). Example: Delete all projects (tuples) that have been ? nished before the actual date (system date): delete from PROJECT where PEND < sysdate; sysdate is a function in SQL that returns the system date. Another important SQL function is user, which returns the name of the user logged into the current Oracle session. 1. 4. 4 Commit and Rollback A sequence of database modi? cations, i. e. , a sequence of insert, update, and delete statements, is called a transaction.Modi? cations of tuples are temporarily stored in the database system. They become permanent only after the statement commit; has been issued. As long as the user has not issued the commit statement, it is possible to undo all modi? cations since the last commit. To undo modi? cations, one has to issue the statement rollback;. It is advisable to complete each modi? cation of the database with a commit (as long as the modi? cation has the expected e? ect). Note that any data de? nition command such as create table results in an internal commit. A commit is also implicitly executed when the user terminates an Oracle session. . 5 Queries (Part II) In Section 1. 2 we have only focused on queries that refer to exactly o ne table. Furthermore, conditions in a where were restricted to simple comparisons. A major feature of relational databases, however, is to combine (join) tuples stored in di? erent tables in order to display more meaningful and complete information. In SQL the select statement is used for this kind of queries joining relations: 11 select [distinct] [. ], . . . , [. ] from [], . . . , [] [where ] The speci? cation of table aliases in the from clause is necessary to refer to columns that have the same name in di? rent tables. For example, the column DEPTNO occurs in both EMP and DEPT. If we want to refer to either of these columns in the where or select clause, a table alias has to be speci? ed and put in the front of the column name. Instead of a table alias also the complete relation name can be put in front of the column such as DEPT. DEPTNO, but this sometimes can lead to rather lengthy query formulations. 1. 5. 1 Joining Relations Comparisons in the where clause are used to comb ine rows from the tables listed in the from clause. Example : In the table EMP only the numbers of the departments are stored, not their name.For each salesman, we now want to retrieve the name as well as the number and the name of the department where he is working: select ENAME, E. DEPTNO, DNAME from EMP E, DEPT D where E. DEPTNO = D. DEPTNO and JOB = ââ¬â¢SALESMANââ¬â¢; Explanation: E and D are table aliases for EMP and DEPT, respectively. The computation of the query result occurs in the following manner (without optimization): 1. Each row from the table EMP is combined with each row from the table DEPT (this operation is called Cartesian product ). If EMP contains m rows and DEPT contains n rows, we thus get n ? m rows. 2.From these rows those that have the same department number are selected (where E. DEPTNO = D. DEPTNO). 3. From this result ? nally all rows are selected for which the condition JOB = ââ¬â¢SALESMANââ¬â¢ holds. In this example the joining condition f or the two tables is based on the equality operator ââ¬Å"=â⬠. The columns compared by this operator are called join columns and the join operation is called an equijoin. Any number of tables can be combined in a select statement. Example: For each project, retrieve its name, the name of its manager, and the name of the department where the manager is working: select ENAME, DNAME, PNAME rom EMP E, DEPT D, PROJECT P where E. EMPNO = P. MGR and D. DEPTNO = E. DEPTNO; 12 It is even possible to join a table with itself: Example: List the names of all employees together with the name of their manager: select E1. ENAME, E2. ENAME from EMP E1, EMP E2 where E1. MGR = E2. EMPNO; Explanation: The join columns are MGR for the table E1 and EMPNO for the table E2. The equijoin comparison is E1. MGR = E2. EMPNO. 1. 5. 2 Subqueries Up to now we have only concentrated on simple comparison conditions in a where clause, i. e. , we have compared a column with a constant or we have compared two c olumns.As we have already seen for the insert statement, queries can be used for assignments to columns. A query result can also be used in a condition of a where clause. In such a case the query is called a subquery and the complete select statement is called a nested query. A respective condition in the where clause then can have one of the following forms: 1. Set-valued subqueries [not] in () [any|all] () An can either be a column or a computed value. 2. Test for (non)existence [not] exists () In a where clause conditions using subqueries can be combined arbitrarily by using the logical connectives and and or.Example: List the name and salary of employees of the department 20 who are leading a project that started before December 31, 1990: select ENAME, SAL from EMP where EMPNO in (select PMGR from PROJECT where PSTART < ââ¬â¢31-DEC-90ââ¬â¢) and DEPTNO =20; Explanation: The subquery retrieves the set of those employees who manage a project that started before December 31, 1 990. If the employee working in department 20 is contained in this set (in operator), this tuple belongs to the query result set. Example: List all employees who are working in a department located in BOSTON: 13 select ? from EMP where DEPTNO in select DEPTNO from DEPT where LOC = ââ¬â¢BOSTONââ¬â¢); The subquery retrieves only one value (the number of the department located in Boston). Thus it is possible to use ââ¬Å"=â⬠instead of in. As long as the result of a subquery is not known in advance, i. e. , whether it is a single value or a set, it is advisable to use the in operator. A subquery may use again a subquery in its where clause. Thus conditions can be nested arbitrarily. An important class of subqueries are those that refer to its surrounding (sub)query and the tables listed in the from clause, respectively. Such type of queries is called correlated subqueries.Example: List all those employees who are working in the same department as their manager (note that co mponents in [ ] are optional: select ? from EMP E1 where DEPTNO in (select DEPTNO from EMP [E] where [E. ]EMPNO = E1. MGR); Explanation: The subquery in this example is related to its surrounding query since it refers to the column E1. MGR. A tuple is selected from the table EMP (E1) for the query result if the value for the column DEPTNO occurs in the set of values select in the subquery. One can think of the evaluation of this query as follows: For each tuple in the table E1, the subquery is evaluated individually.If the condition where DEPTNO in . . . evaluates to true, this tuple is selected. Note that an alias for the table EMP in the subquery is not necessary since columns without a preceding alias listed there always refer to the innermost query and tables. Conditions of the form [any|all] are used to compare a given with each value selected by . â⬠¢ For the clause any, the condition evaluates to true if there exists at least on row selected by the subquery for which the comparison holds. If the subquery yields an empty result set, the condition is not satis? ed. For the clause all, in contrast, the condition evaluates to true if for all rows selected by the subquery the comparison holds. In this case the condition evaluates to true if the subquery does not yield any row or value. Example: Retrieve all employees who are working in department 10 and who earn at least as much as any (i. e. , at least one) employee working in department 30: select ? from EMP where SAL >= any (select SAL from EMP where DEPTNO = 30) and DEPTNO = 10; 14 Note: Also in this subquery no aliases are necessary since the columns refer to the innermost from clause.Example: List all employees who are not working in department 30 and who earn more than all employees working in department 30: select ? from EMP where SAL > all (select SAL from EMP where DEPTNO = 30) and DEPTNO 30; For all and any, the following equivalences hold: in ? = any not in ? all or ! = all Often a query resu lt depends on whether certain rows do (not) exist in (other) tables. Such type of queries is formulated using the exists operator. Example: List all departments that have no employees: select ? from DEPT where not exists (select ? from EMP where DEPTNO = DEPT.DEPTNO); Explanation: For each tuple from the table DEPT, the condition is checked whether there exists a tuple in the table EMP that has the same department number (DEPT. DEPTNO). In case no such tuple exists, the condition is satis? ed for the tuple under consideration and it is selected. If there exists a corresponding tuple in the table EMP, the tuple is not selected. 1. 5. 3 Operations on Result Sets Sometimes it is useful to combine query results from two or more queries into a single result. SQL supports three set operators which have the pattern: The set operators are: union [all] returns a table consisting of all rows either appearing in the result of or in the result of . Duplicates are automatically eliminated unless the clause all is used. â⬠¢ intersect returns all rows that appear in both results and . â⬠¢ minus returns those rows that appear in the result of but not in the result of . 15 Example: Assume that we have a table EMP2 that has the same structure and columns as the table EMP: â⬠¢ All employee numbers and names from both tables: select EMPNO, ENAME from EMP union select EMPNO, ENAME from EMP2; â⬠¢ Employees who are listed in both EMP and EMP2: select ? from EMP intersect select ? from EMP2; Employees who are only listed in EMP: select ? from EMP minus select ? from EMP2; Each operator requires that both tables have the same data types for the columns to which the operator is applied. 1. 5. 4 Grouping In Section 1. 2. 4 we have seen how aggregate functions can be used to compute a single value for a column. Often applications require grouping rows that have certain properties and then applying an aggregate function on one column for each group separately. For this, SQ L provides the clause group by . This clause appears after the where clause and must refer to columns of tables listed in the from clause. select from here group by [having ]; Those rows retrieved by the selected clause that have the same value(s) for are grouped. Aggregations speci? ed in the select clause are then applied to each group separately. It is important that only those columns that appear in the clause can be listed without an aggregate function in the select clause ! Example: For each department, we want to retrieve the minimum and maximum salary. select DEPTNO, min(SAL), max(SAL) from EMP group by DEPTNO; Rows from the table EMP are grouped such that all rows in a group have the same department number. The aggregate functions are then applied to each such group.We thus get the following query result: 16 DEPTNO 10 20 30 MIN(SAL) 1300 800 950 MAX(SAL) 5000 3000 2850 Rows to form a group can be restricted in the where clause. For example, if we add the condition where JOB = ââ¬â¢CLERKââ¬â¢, only respective rows build a group. The query then would retrieve the minimum and maximum salary of all clerks for each department. Note that is not allowed to specify any other column than DEPTNO without an aggregate function in the select clause since this is the only column listed in the group by clause (is it also easy to see that other columns would not make any sense).Once groups have been formed, certain groups can be eliminated based on their properties, e. g. , if a group contains less than three rows. This type of condition is speci? ed using the having clause. As for the select clause also in a having clause only and aggregations can be used. Example: Retrieve the minimum and maximum salary of clerks for each department having more than three clerks. select DEPTNO, min(SAL), max(SAL) from EMP where JOB = ââ¬â¢CLERKââ¬â¢ group by DEPTNO having count(? ) > 3; Note that it is even possible to specify a subquery in a having clause.In the above query, for example, instead of the constant 3, a subquery can be speci? ed. A query containing a group by clause is processed in the following way: 1. Select all rows that satisfy the condition speci? ed in the where clause. 2. From these rows form groups according to the group by clause. 3. Discard all groups that do not satisfy the condition in the having clause. 4. Apply aggregate functions to each group. 5. Retrieve values for the columns and aggregations listed in the select clause. 1. 5. 5 Some Comments on Tables Accessing tables of other usersProvided that a user has the privilege to access tables of other users (see also Section 3), she/he can refer to these tables in her/his queries. Let be a user in the Oracle system and a table of this user. This table can be accessed by other (privileged) users using the command select ? from . ; 17 In case that one often refers to tables of other users, it is useful to use a synonym instead of .. In Oracle-SQL a synonym can be created u sing the command create synonym for . ; It is then possible to use simply in a from clause. Synonyms can also be created for oneââ¬â¢s own tables. Adding Comments to De? nitionsFor applications that include numerous tables, it is useful to add comments on table de? nitions or to add comments on columns. A comment on a table can be created using the command comment on table is ââ¬â¢Ã¢â¬â¢; A comment on a column can be created using the command comment on column . is ââ¬â¢Ã¢â¬â¢; Comments on tables and columns are stored in the data dictionary. They can be accessed using the data dictionary views USER TAB COMMENTS and USER COL COMMENTS (see also Section 3). Modifying Table- and Column De? nitions It is possible to modify the structure of a table (the relation schema) even if rows have already been inserted into this table.A column can be added using the alter table command alter table add( [default ] []); If more than only one column should be added at one time, respectiv e add clauses need to be separated by colons. A table constraint can be added to a table using alter table add (); Note that a column constraint is a table constraint, too. not null and primary key constraints can only be added to a table if none of the speci? ed columns contains a null value. Table de? nitions can be modi? ed in an analogous way. This is useful, e. g. , when the size of strings that can be stored needs to be increased.The syntax of the command for modifying a column is alter table modify( [] [default ] []); Note: In earlier versions of Oracle it is not possible to delete single columns from a table de? nition. A workaround is to create a temporary table and to copy respective columns and rows into this new table. Furthermore, it is not possible to rename tables or columns. In the most recent version (9i), using the alter table command, it is possible to rename a table, columns, and constraints. In this version, there also exists a drop column clause as part of the alter table statement. Deleting a TableA table and its rows can be deleted by issuing the command drop table [cascade constraints];. 18 1. 6 Views In Oracle the SQL command to create a view (virtual table) has the form create [or replace] view [()] as [with check option [constraint ]]; The optional clause or replace re-creates the view if it already exists. names the columns of the view. If is not speci? ed in the view de? nition, the columns of the view get the same names as the attributes listed in the select statement (if possible). Example: The following view contains the name, job title and the annual salary of employees working in the department 20: create view DEPT20 as elect ENAME, JOB, SAL? 12 ANNUAL SALARY from EMP where DEPTNO = 20; In the select statement the column alias ANNUAL SALARY is speci? ed for the expression SAL? 12 and this alias is taken by the view. An alternative formulation of the above view de? nition is create view DEPT20 (ENAME, JOB, ANNUAL SALARY) as se lect ENAME, JOB, SAL ? 12 from EMP where DEPTNO = 20; A view can be used in the same way as a table, that is, rows can be retrieved from a view (also respective rows are not physically stored, but derived on basis of the select statement in the view de? ition), or rows can even be modi? ed. A view is evaluated again each time it is accessed. In Oracle SQL no insert, update, or delete modi? cations on views are allowed that use one of the following constructs in the view de? nition: â⬠¢ Joins â⬠¢ Aggregate function such as sum, min, max etc. â⬠¢ set-valued subqueries (in, any, all) or test for existence (exists) â⬠¢ group by clause or distinct clause In combination with the clause with check option any update or insertion of a row into the view is rejected if the new/modi? ed row does not meet the view de? nition, i. e. these rows would not be selected based on the select statement. A with check option can be named using the constraint clause. A view can be deleted us ing the command delete . 19 2 SQL*Plus Introduction SQL*Plus is the interactive (low-level) user interface to the Oracle database management system. Typically, SQL*Plus is used to issue ad-hoc queries and to view the query result on the screen. Some of the features of SQL*Plus are: â⬠¢ A built-in command line editor can be used to edit (incorrect) SQL queries. Instead of this line editor any editor installed on the computer can be invoked. There are numerous commands to format the output of a query. â⬠¢ SQL*Plus provides an online-help. â⬠¢ Query results can be stored in ? les which then can be printed. Queries that are frequently issued can be saved to a ? le and invoked later. Queries can be parameterized such that it is possible to invoke a saved query with a parameter. A Minimal User Guide Before you start SQL*Plus make sure that the following UNIX shell variables are properly set (shell variables can be checked using the env command, e. g. , env | grep ORACLE): â⠬ ¢ ORACLE HOME, e. g. , ORACLE HOME=/usr/pkg/oracle/734 â⬠¢ ORACLE SID, e. , ORACLE SID=prod In order to invoke SQL*Plus from a UNIX shell, the command sqlplus has to be issued. SQL*Plus then displays some information about the product, and prompts you for your user name and password for the Oracle system. gertz(catbert)54: sqlplus SQL*Plus: Release 3. 3. 4. 0. 1 ââ¬â Production on Sun Dec 20 19:16:52 1998 Copyright (c) Oracle Corporation 1979, 1996. All rights reserved. Enter user-name: scott Enter password: Connected to: Oracle7 Server Release 7. 3. 4. 0. 1 ââ¬â Production Release With the distributed option PL/SQL Release 2. 3. 4. 0. 0 ââ¬â Production SQL> 20SQL> is the prompt you get when you are connected to the Oracle database system. In SQL*Plus you can divide a statement into separate lines, each continuing line is indicated by a prompt such 2>, 3> etc. An SQL statement must always be terminated by a semicolon (;). In addition to the SQL statements discussed in the previous section, SQL*Plus provides some special SQL*Plus commands. These commands need not be terminated by a semicolon. Upper and lower case letters are only important for string comparisons. An SQL query can always be interrupted by using C. To exit SQL*Plus you can either type exit or quit.Editor Commands The most recently issued SQL statement is stored in the SQL bu? er, independent of whether the statement has a correct syntax or not. You can edit the bu? er using the following commands: â⬠¢ l[ist] lists all lines in the SQL bu? er and sets the current line (marked with an â⬠? â⬠) to the last line in the bu? er. â⬠¢ l sets the actual line to â⬠¢ c[hange]// replaces the ? rst occurrence of by (for the actual line) â⬠¢ a[ppend] appends to the current line â⬠¢ del deletes the current line â⬠¢ r[un] executes the current bu? er contents â⬠¢ get reads the data from the ? le into the bu? er â⬠¢ save writes the current bu? r into the ? le â⬠¢ edit invokes an editor and loads the current bu? er into the editor. After exiting the editor the modi? ed SQL statement is stored in the bu? er and can be executed (command r). The editor can be de? ned in the SQL*Plus shell by typing the command de? ne editor = , where can be any editor such as emacs, vi, joe, or jove. SQL*Plus Help System and Other Useful Commands â⬠¢ To get the online help in SQL*Plus just type help , or just help to get information about how to use the help command. In Oracle Version 7 one can get the complete list of possible commands by typing help command. To change the password, in Oracle Version 7 the command alter user identi? ed by ; is used. In Oracle Version 8 the command passw prompts the user for the old/new password. â⬠¢ The command desc[ribe] lists all columns of the given table together with their data types and information about whether null values are allowed or not. â⬠¢ You can invoke a UNIX command from the SQL*Plus she ll by using host . For example, host ls -la *. sql lists all SQL ? les in the current directory. 21 â⬠¢ You can log your SQL*Plus session and thus queries and query results by using the command spool .All information displayed on screen is then stored in which automatically gets the extension . lst. The command spool o? turns spooling o?. â⬠¢ The command copy can be used to copy a complete table. For example, the command copy from scott/tiger create EMPL using select ? from EMP; copies the table EMP of the user scott with password tiger into the relation EMPL. The relation EMP is automatically created and its structure is derived based on the attributes listed in the select clause. â⬠¢ SQL commands saved in a ? le . sql can be loaded into SQL*Plus and executed using the command @. Comments are introduced by the clause rem[ark] (only allowed between SQL statements), or ââ¬â ââ¬â (allowed within SQL statements). Formatting the Output SQL*Plus provides numerous comm ands to format query results and to build simple reports. For this, format variables are set and these settings are only valid during the SQL*Plus session. They get lost after terminating SQL*Plus. It is, however, possible to save settings in a ? le named login. sql in your home directory. Each time you invoke SQL*Plus this ? le is automatically loaded. The command column . . . is used to format columns of your query result.The most frequently used options are: â⬠¢ format A For alphanumeric data, this option sets the length of to . For columns having the data type number, the format command can be used to specify the format before and after the decimal point. For example, format 99,999. 99 speci? es that if a value has more than three digits in front of the decimal point, digits are separated by a colon, and only two digits are displayed after the decimal point. â⬠¢ The option heading relabels and gives it a new heading. â⬠¢ null is used to specify the output of null val ues (typically, null values are not displayed). column clear deletes the format de? nitions for . The command set linesize can be used to set the maximum length of a single line that can be displayed on screen. set pagesize sets the total number of lines SQL*Plus displays before printing the column names and headings, respectively, of the selected rows. Several other formatting features can be enabled by setting SQL*Plus variables. The command show all displays all variables and their current values. To set a variable, type set . For example, set timing on causes SQL*Plus to display timing statistics for each SQL command that is executed. et pause on [] makes SQL*Plus wait for you to press Return after the number of lines de? ned by set pagesize has been displayed. is the message SQL*Plus will display at the bottom of the screen as it waits for you to hit Return. 22 3 Oracle Data Dictionary The Oracle data dictionary is one of the most important components of the Oracle DBMS. It con tains all information about the structures and objects of the database such as tables, columns, users, data ? les etc. The data stored in the data dictionary are also often called metadata.Although it is usually the domain of database administrators (DBAs), the data dictionary is a valuable source of information for end users and developers. The data dictionary consists of two levels: the internal level contains all base tables that are used by the various DBMS software components and they are normally not accessible by end users. The external level provides numerous views on these base tables to access information about objects and structures at di? erent levels of detail. 3. 1 Data Dictionary Tables An installation of an Oracle database always includes the creation of three standard Oracle users: SYS: This is the owner of all data dictionary tables and views. This user has the highest privileges to manage objects and structures of an Oracle database such as creating new users. â⠬ ¢ SYSTEM: is the owner of tables used by di? erent tools such SQL*Forms, SQL*Reports etc. This user has less privileges than SYS. â⬠¢ PUBLIC: This is a ââ¬Å"dummyâ⬠user in an Oracle database. All privileges assigned to this user are automatically assigned to all users known in the database. The tables and views provided by the data dictionary contain information about â⬠¢ users and their privileges, tables, table columns and their data types, integrity constraints, indexes, â⬠¢ statistics about tables and indexes used by the optimizer, â⬠¢ privileges granted on database objects, â⬠¢ storage structures of the database. The SQL command select ? from DICT[IONARY]; lists all tables and views of the data dictionary that are accessible to the user. The selected information includes the name and a short description of each table and view. Before issuing this query, check the column de? nitions of DICT[IONARY] using desc DICT[IONARY] and set the appropriate va lues for column using the format command. The query select ? from TAB; etrieves the names of all tables owned by the user who issues this command. The query select ? from COL; 23 returns all information about the columns of oneââ¬â¢s own tables. Each SQL query requires various internal accesses to the tables and views of the data dictionary. Since the data dictionary itself consists of tables, Oracle has to generate numerous SQL statements to check whether the SQL command issued by a user is correct and can be executed. Example: The SQL query select ? from EMP where SAL > 2000; requires a veri? cation whether (1) the table EMP exists, (2) the user has the privilege to access this table, (3) the column SAL is de? ed for this table etc. 3. 2 Data Dictionary Views The external level of the data dictionary provides users a front end to access information relevant to the users. This level provides numerous views (in Oracle7 approximately 540) that represent (a portion of the) data fro m the base tables in a readable and understandable manner. These views can be used in SQL queries just like normal tables. The views provided by the data dictionary are divided into three groups: USER, ALL, and DBA. The group name builds the pre? x for each view name. For some views, there are associated synonyms as given in brackets below. USER : Tuples in the USER views contain information about objects owned by the account performing the SQL query (current user) USER TABLES USER USER USER USER USER USER CATALOG COL COMMENTS CONSTRAINTS INDEXES OBJECTS TAB COLUMNS USER USER USER USER TAB COMMENTS TRIGGERS USERS VIEWS all tables with their name, number of columns, storage information, statistical information etc. (TABS) tables, views, and synonyms (CAT) comments on columns constraint de? nitions for tables all information about indexes created for tables (IND) all database objects owned by the user (OBJ) columns of the tables and views owned by the user COLS) comments on tables and views triggers de? ned by the user information about the current user views de? ned by the user â⬠¢ ALL : Rows in the ALL views include rows of the USER views and all information about objects that are accessible to the current user. The structure of these views is analogous to the structure of the USER views. 24 ALL CATALOG owner, name and type of all accessible tables, views, and synonyms ALL TABLES owner and name of all accessible tables ALL OBJECTS owner, type, and name of accessible database objects ALL TRIGGERS . . . ALL USERS â⬠¦ ALL VIEWS â⬠¦ DBA : The DBA views encompass information about all database objects, regardless of the owner. Only users with DBA privileges can access these views. DBA DBA DBA DBA DBA TABLES CATALOG OBJECTS DATA FILES USERS tables of all users in the database tables, views, and synonyms de? ned in the database object of all users information about data ? les information about all users known in the database 25 4 Application Programming 4 . 1 4. 1. 1 PL/SQL Introduction The development of database applications typically requires language constructs similar to those that can be found in programming languages such as C, C++, or Pascal.These constructs are necessary in order to implement complex data structures and algorithms. A major restriction of the database language SQL, however, is that many tasks cannot be accomplished by using only the provided language elements. PL/SQL (Procedural Language/SQL) is a procedural extension of Oracle-SQL that o? ers language constructs similar to those in imperative programming languages. PL/SQL allows users and designers to develop complex database applications that require the usage of control structures and procedural elements such as procedures, functions, and modules. The basic construct in PL/SQL is a block.Blocks allow designers to combine logically related (SQL-) statements into units. In a block, constants and variables can be declared, and variables can be used to store q uery results. Statements in a PL/SQL block include SQL statements, control structures (loops), condition statements (if-then-else), exception handling, and calls of other PL/SQL blocks. PL/SQL blocks that specify procedures and functions can be grouped into packages. A package is similar to a module and has an interface and an implementation part. Oracle o? ers several prede? ned packages, for example, input/output routines, ? le handling, job scheduling etc. see directory $ORACLE HOME/rdbms/admin). Another important feature of PL/SQL is that it o? ers a mechanism to process query results in a tuple-oriented way, that is, one tuple at a time. For this, cursors are used. A cursor basically is a pointer to a query result and is used to read attribute values of selected tuples into variables. A cursor typically is used in combination with a loop construct such that each tuple read by the cursor can be processed individually. In summary, the major goals of PL/SQL are to â⬠¢ increase the expressiveness of SQL, â⬠¢ process query results in a tuple-oriented way, â⬠¢ optimize combined SQL statements, develop modular database application programs, â⬠¢ reuse program code, and â⬠¢ reduce the cost for maintaining and changing applications. 26 4. 1. 2 Structure of PL/SQL-Blocks PL/SQL is a block-structured language. Each block builds a (named) program unit, and blocks can be nested. Blocks that build a procedure, a function, or a package must be named. A PL/SQL block has an optional declare section, a part containing PL/SQL statements, and an optional exception-handling part. Thus the structure of a PL/SQL looks as follows (brackets [ ] enclose optional parts): [] [declare ] begin [exception ] end; The block header speci? s whether the PL/SQL block is a procedure, a function, or a package. If no header is speci? ed, the block is said to be an anonymous PL/SQL block. Each PL/SQL block again builds a PL/SQL statement. Thus blocks can be nested like blocks in conventional programming languages. The scope of declared variables (i. e. , the part of the program in which one can refer to the variable) is analogous to the scope of variables in programming languages such as C or Pascal. 4. 1. 3 Declarations Constants, variables, cursors, and exceptions used in a PL/SQL block must be declared in the declare section of that block.Variables and constants can be declared as follows: [constant] [not null] [:= ]; Valid data types are SQL data types (see Section 1. 1) and the data type boolean. Boolean data may only be true, false, or null. The not null clause requires that the declared variable must always have a value di? erent from null. is used to initialize a variable. If no expression is speci? ed, the value null is assigned to the variable. The clause constant states that once a value has been assigned to the variable, the value cannot be changed (thus the variable becomes a constant). Example: declare hire date job title mp found salary i ncr â⬠¦ begin . . . end; date; /* implicit initialization with null */ varchar2(80) := ââ¬â¢Salesmanââ¬â¢; boolean; /* implicit initialization with null */ constant number(3,2) := 1. 5; /* constant */ 27 Instead of specifying a data type, one can also refer to the data type of a table column (so-called anchored declaration). For example, EMP. Empno%TYPE refers to the data type of the column Empno in the relation EMP. Instead of a single variable, a record can be declared that can store a complete tuple from a given table (or query result). For example, the data type DEPT%ROWTYPE speci? s a record suitable to store all attribute values of a complete row from the table DEPT. Such records are typically used in combination with a cursor. A ? eld in a record can be accessed using . , for example, DEPT. Deptno. A cursor declaration speci? es a set of tuples (as a query result) such that the tuples can be processed in a tuple-oriented way (i. e. , one tuple at a time) using the f etch statement. A cursor declaration has the form cursor [()] is ; The cursor name is an undeclared identi? er, not the name of any PL/SQL variable. A parameter has the form . Possible parameter types are char, archar2, number, date and boolean as well as corresponding subtypes such as integer. Parameters are used to assign values to the variables that are given in the select statement. Example: We want to retrieve the following attribute values from the table EMP in a tupleoriented way: the job title and name of those employees who have been hired after a given date, and who have a manager working in a given department. cursor employee cur (start date date, dno number) is select JOB, ENAME from EMP E where HIREDATE > start date and exists (select ? from EMP where E. MGR = EMPNO and DEPTNO = dno);If (some) tuples selected by the cursor will be modi? ed in the PL/SQL block, the clause for update[()] has to be added at the end of the cursor declaration. In this case selected tuples ar e locked and cannot be accessed by other users until a commit has been issued. Before a declared cursor can be used in PL/SQL statements, the cursor must be opened, and after processing the selected tuples the cursor must be closed. We discuss the usage of cursors in more detail below. Exceptions are used to process errors and warnings that occur during the execution of PL/SQL statements in a controlled manner.Some exceptions are internally de? ned, such as ZERO DIVIDE. Other exceptions can be speci? ed by the user at the end of a PL/SQL block. User de? ned exceptions need to be declared using exception. We will discuss exception handling in more detail in Section 4. 1. 5 4. 1. 4 Language Elements In addition to the declaration of variables, constants, and cursors, PL/SQL o? ers various language constructs such as variable assignments, control structures (loops, if-then-else), procedure and function calls, etc. However, PL/SQL does not allow commands of the SQL data de? nition langu age such as the create table statement.For this, PL/SQL provides special packages. 28 Furthermore, PL/SQL uses a modi? ed select statement that requires each selected tuple to be assigned to a record (or a list of variables). There are several alternatives in PL/SQL to a assign a value to a variable. The most simple way to assign a value to a variable is declare counter integer := 0; â⬠¦ begin counter := counter + 1; Values to assign to a variable can also be retrieved from the database using a select statement select into from where ; It is important to ensure that the select statement retrieves at most one tuple !Otherwise it is not possible to assign the attribute values to the speci? ed list of variables and a runtime error occurs. If the select statement retrieves more than one tuple, a cursor must be used instead. Furthermore, the data types of the speci? ed variables must match those of the retrieved attribute values. For most data types, PL/SQL performs an automatic type conversion (e. g. , from integer to real). Instead of a list of single variables, a record can be given after the keyword into. Also in this case, the select statement must retrieve at most one tuple ! declare mployee rec EMP%ROWTYPE; max sal EMP. SAL%TYPE; begin select EMPNO, ENAME, JOB, MGR, SAL, COMM, HIREDATE, DEPTNO into employee rec from EMP where EMPNO = 5698; select max(SAL) into max sal from EMP; â⬠¦ end; PL/SQL provides while-loops, two types of for-loops, and continuous loops. Latter ones are used in combination with cursors. All types of loops are used to execute a sequence of statements multiple times. The speci? cation of loops occurs in the same way as known from imperative programming languages such as C or Pascal. A while-loop has the pattern [>] while loop ; end loop [] ; 9 A loop can be named. Naming a loop is useful whenever loops are nested and inner loops are completed unconditionally using the exit ; statement. Whereas the number of iterations through a w hile loop is unknown until the loop completes, the number of iterations through the for loop can be speci? ed using two integers. [>] for in [reverse] .. loop end loop [] ; The loop counter is declared implicitly. The scope of the loop counter is only the for loop. It overrides the scope of any variable having the same name outside the loop. Inside the for loop, can be referenced like a constant. ay appear in expressions, but one cannot assign a value to . Using the keyword reverse causes the iteration to proceed downwards from the higher bound to the lower bound. Processing Cursors: Before a cursor can be used, it must be opened using the open statement open [()] ; The associated select statement then is processed and the cursor references the ? rst selected tuple. Selected tuples then can be processed one tuple at a time using the fetch command fetch into ; The fetch command assigns the selected attribute values of the current tuple to the list of variables.After the fetch command , the cursor advances to the next tuple in the result set. Note that the variables in the list must have the same data types as the selected values. After all tuples have been processed, the close command is used to disable the cursor. close ; The example below illustrates how a cursor is used together with a continuous loop: declare cursor emp cur is select ? from EMP; emp rec EMP%ROWTYPE; emp sal EMP. SAL%TYPE; begin open emp cur; loop fetch emp cur into emp rec; exit when emp cur%NOTFOUND; emp sal := emp rec. sal; end loop; close emp cur; â⬠¦ end; 30Each loop can be completed unconditionally using the exit clause: exit [] [when ] Using exit without a block label causes the completion of the loop that contains the exit statement. A condition can be a simple comparison of values. In most cases, however, the condition refers to a cursor. In the example above, %NOTFOUND is a predicate that evaluates to false if the most recent fetch command has read a tuple. The value of %NOTFOUN D is null before the ? rst tuple is fetched. The predicate evaluates to true if the most recent fetch failed to return a tuple, and false otherwise. FOUND is the logical opposite of %NOTFOUND. Cursor for loops can be used to simplify the usage of a cursor: [>] for in [()] loop end loop []; A record suitable to store a tuple fetched by the cursor is implicitly declared. Furthermore, this loop implicitly performs a fetch at each iteration as well as an open before the loop is entered and a close after the loop is left. If at an iteration no tuple has been fetched, the loop is automatically terminated without an exit. It is even possible to specify a query instead of in a for loop: for in () loop end loop; That is, a cursor needs not be speci? d before the loop is entered, but is de? ned in the select statement. Example: for sal rec in (select SAL + COMM total from EMP) loop â⬠¦ ; end loop; total is an alias for the expression computed in the select statement. Thus, at each iterati on only one tuple is fetched. The record sal rec, which is implicitly de? ned, then contains only one entry which can be accessed using sal rec. total. Aliases, of course, are not necessary if only attributes are selected, that is, if the select statement contains no arithmetic operators or aggregate functions. For conditional control, PL/SQL o? rs if-then-else
Thursday, January 2, 2020
Fighting Fire With Fire Essay - 1742 Words
Kyle Brinkley Mrs. Gallos English 3 Honors 27 March 2017 Fighting Fire With Fire Many people have heard the phrase ââ¬Å"fight fire with fireâ⬠, but what most people do not realize is that this is one of the most practical and efficient ways to prevent and stop wild fires. Wildfires are naturally occurring events that will happen despite any effort to prevent them. The thing people can do is reduce the severity and amount of wildfires by many different tactics. There are organizations all over the world from federal to private with the goal to reduce wildfires. The most widely known organization uses the iconic bear, Smokey, who says ââ¬Å"Only you can prevent Wildfiresâ⬠(ââ¬Å"About The Campaignâ⬠). Fires need three factors to allow them to burn:â⬠¦show more contentâ⬠¦The reason behind this is the controlled fire kills the underbrush, and the fuel to the main fire will contain or at least slow down the wildfire. This tactic takes away the fires fuel, which is one of the three key factors, therefore being a very effective tactic. There are drawbacks, however. By starting a fire, there is always a chance of it becoming uncontained. If this fire gets too hot and jumps the fire line, then what was a controlled burn becomes a wildfire. Fighting fire with fire works only when it is done correctly. The Federal Government caused some problems in the early 1900s, by trying to prevent wildfires which in turn caused more. The Federal Government completely outlawed fires in the southwest, which is where most large wildfires occur. Due to this new law, the southwest saw something unexpected. Instead of there being a decrease in wildfires, there was a drastic increase. Wildfires were burning more regularly and larger than ever before. This soon became known as the ââ¬Å"Smokey Bear effectâ⬠. The reason the fires increased was because their fuel just continued to build up over time; therefore, when a fire began, it had plenty of fuel to help it continue to burn. ââ¬Å"Southwestern mountains of New Mexico, Arizona, Color ado and Utah are now choked with trees of all sizes, and grass and shrubs. Essentially, it is fuelâ⬠(ââ¬Å"Howâ⬠).The experts found that the only solution to this problem is the problem itself: fire. Controlled burns are what and stillShow MoreRelated Fire Fighting Technology Essay888 Words à |à 4 PagesFire Fighting Technology Innovations in Communication Technology This 80,000 pound powerhouse was just purchased by the Swarthmore Fire Protective Association. Equipped with a 100-foot aerial and a 2000 gallon per minute (gpm) Hale single stage pump, Tower 14 can knock down just about any fire. The first five minutes after the first fire apparatus arrives on scene at a large-scale fire are coordinated chaos. Joe Lombardo of the Garden City Fire Department made it a point duringRead MoreRisky Business: Consent Safety and Fire Fighting Culture. Essay670 Words à |à 3 PagesRisky Business: Consent Safety and fire fighting Culture. This case study introduces us to the risk, safety measures, and issues involved in fire fighting. The title of the case study is Risky Business: Consent Safety and fire fighting Culture. The case discusses the Bay City fire fighting department which is known ââ¬Å"as one of the most advanced in the countryâ⬠(2010). The case highlights the fact that though the department has one of the most highly trained fire fighters in its team, the chief isRead MoreComparative Essay- Rachel Orbach In ââ¬Å"The Masque of the Red Deathâ⬠by Edgar Allan Poe, and ââ¬Å"To900 Words à |à 4 Pages Comparative Essay- Rachel Orbach In ââ¬Å"The Masque of the Red Deathâ⬠by Edgar Allan Poe, and ââ¬Å"To Build a Fireâ⬠by Jack London, both authors use similar protagonists who unwillingly have to face their death. Prince Prospero, in ââ¬Å"The Masque of Red Deathâ⬠, is avoiding a deadly plague by hiding in his castle with his kinsmen, and the man in ââ¬Å"To Build a Fireâ⬠is traveling in the freezing weather trying to abstain from hypothermia and death. Prince Prospero and the man, while different from one anotherRead MoreSimilarities and Differences Between Romeo and Juliet and Lord of the Flies1676 Words à |à 7 Pages1. How does civilization breakdown as time passes in RJ and LOTF? â⬠¢ Montague and Capulet families have been bitter enemies for generations. â⬠¢ Bitter hate even extend to the familiesââ¬â¢ servants who open the play fighting in the streets. â⬠¢ Arguments end up in fights resulting in murder, followed by revenge and more murder ââ¬â Tybalt kills Mercutio, Romeo kills Tybalt despite knowing that Tybalt is his new wifeââ¬â¢s cousin. â⬠¢ Juliet finds out that Romeo kills her cousin, but tolerates it. â⬠¢ Juliet wouldRead MoreWilliam Shakespeare s The Night 1662 Words à |à 7 Pagesawait Composed only of which you fear The dangers come my way And may danger me true But if you cannot fix it The fault belongs to you So I leave you with my warning Be it known from Fire to Earth Not acting within two months And I shall have my mirth The whole twenty-five membered council exchanged fearful glances at the end of the reading. One man however, born of noble Air descent, felt the panic illogicalRead MoreThe Symbolism of Fire in Fahrenheit 451790 Words à |à 4 PagesThe Symbolism of fire in Fahrenheit 451 Fahrenheit 451 by Ray Bradbury describes a dystopian society where firemen instead of putting out fires, light them in pursuit of vanishing all books. The protagonist of the novel, Guy Montag, is a fireman that started questioning his beliefs about love, society and mainly questioning his job as an enemy of books, and the use of fire. This essay will discuss how does Montag understands fire through the novel and how fire is presented in the book. Read MoreComparison of Franco Zefferelliââ¬â¢s Romeo and Juliet to The Adaptation by Baz Luhrmann1460 Words à |à 6 PagesComparison of Franco Zefferelliââ¬â¢s Romeo and Juliet to The Adaptation by Baz Luhrmann This essay aims to discus the similarities and differences of Shakespeareââ¬â¢s Romeo and Juliet, directed by Franco Zefferelli and Baz Luhrmann. In this essay there will be an outline of the story, a comparison of the techniques used in each film and the affect these techniques have on the viewer. In Fair Verona two families have been feuding for generations, the Capulets and the MontaguesRead MoreEssay about The Fire Next Time by James Baldwin735 Words à |à 3 PagesThe Fire Next Time by James Baldwin James Baldwins book The fire Next Time opens up an entirely new world to most readers. It opens the reader to the harsh world of a black boy growing into a man in the poor city slums and all of the issues that a black man has to face. This book does more for the reader than any article published about the blacks living in the poor cities in terms of exposure for the reader. The reason why it hasRead MoreWar As A Fundamental Way Of War1247 Words à |à 5 Pagesbeginning of time, humanity has resorted to war as a fundamental way to settle their differences. Clausewitz described war as the act of force to compel the enemy to do our will. Sun-Tzu believed the purpose of war was to subdue the enemy without fighting. Regardless of the definition, every culture has its motives for why it goes to war and how it should be conducted. Nation states go to war to gain access to new territories and resources, settle religious differences, and defend against a threatRead MoreETA is a Terrorist Organization with Roots in Ethnic Nationalism1072 Words à |à 4 Pages ETA Discursive Essay: From 1959 until 2010, Euskadi Ta Aaskatasuna or ETA has been fighting for autonomy in the Basque region on the border between Spain and France. ETA hopes to achieve political and cultural independence. However, it utilizes terror and violent intimidation to undermine existing governments. It is a terrorist organization that with military-style precision inflicts maximum damage in an attempt to realize its nationalist ideals. Cease-fires and negotiations are voided. ETA argues
Subscribe to:
Posts (Atom)