***** 1 *****


















***** 2 *****

CLIENT SERVER COMPUTING ARCHITECTURE It consists of two or more computers designated as client machine running an application program which communicates with remote computer designated as server machine which serves request from client machine. In basic model of client server computing, RDBMS resides on server machine. The application program which resides on client machine interfaces with client software called middleware that are responsible for communicating request & results between their application programs and RDBMS.





CLIENT The Client is the front END application of a database which interacts with the server. The Client has more responsibility for accessing the data, it concentrates on the requests. The processing and presentation is managed by the server. SERVER The Server executes the Oracle software and these with the function required for simultaneous and shared data excess. The server receives and processes the SQl and PL/SQL declaration and that originates in the client application.

***** 3 *****

It can work on any type of operating system eg. Distributed computing as the servers act as a focal point for data management. of resource become a bottle neck in the processing and distribution of data to the client  consumers. ADVANTAGES OF CLIENT SERVER MODEL          It allows the user to work in extensible form.e. Win 98. LINUX. Since the importance software is on a server and in a more controlled environment. the design of this architecture scales up. The same database is shared by different clients. DISADVANTAGES OF CLIENT SERVER MODEL  Bottleneck: If a significant portion of application layer is moved to a server. UNIX.  there is less worry about security. It provides the facility to establish the link between remote databases. the server may Server limited resources will be in over higher demanding by the increasing no. Better application performance and network usage i. The support and installation cost of maintaining the software on a single server is much less than trying to maintain the same software on 100’s of PC’s. Client requests services whereas the server it provides its services.There are two types of Client Server Model are  Two tier Client Server Model  Three tier client Server Model  Two tier Client Server Model: It improves the scalability by allowing upto 100’s of user and is very flexible for data sharing. It is multiplatform and centralized. it reduces the network time. Provides flexibility and full utilization of all resources. ***** 4 ***** . There is one limitation of this tier i.e. It provides the facility of fast accessing of information and processing of data. There are three components of client of this tier:  User System interface  Processing Management  Database Management Three Tier Client Server Model: When the less software is on the client.

Nowadays commonly used versions of oracle are ORACLE 8. Oracle is one of the powerful RDBMS product that provide efficient solutions for database applications. The first commercial product of oracle was delivered in 1970. features and functionality.0 was written in assembly language. Oracle server tools are also called as back end. This program must be loaded in RAM to that it can process the user requests. Oracle server takes care of following functions. 8i & 9i Oracle 8 and onwards provide tremendous increase in performance. ORACLE Security features: It has to take care of the security of the database from unauthorized access. FEATURES OF ORACLE  Client/Server Architecture  Large database and Space Management  Concurrent Processing  High transaction processing performance  High Availability  Many concurrent database users  Controlled availability  Openness industry standards  Manageable security  Database enforced integrity  Distributed systems  Portability  Compatibility ORACLE SERVER TOOL Oracle is a company that produces most widely used server based multi-user RDBMS. Oracle is the product of Oracle Corporation which was founded by LAWRENCE ELLISION in 1977. Oracle server is a program installed on server hard-disk drive. The first version of oracle 2. Functions of server tool:  Updates the data  Retrieves the data sharing ***** 5 ***** .

creating indexes and modify relation schemas. Two types of DML are  Procedural DML  Non-procedural DML Following are DML commands are   Select Update ***** 6 ***** . The sql provides various commands for defining relation schemas. deleting relations. It provides facilities to work on database objects. DDL is part of sql which helps a user in defining the data structures into the database.  Insertion of new information into database. By data manipulation we have  Retrieval of information stored in database.  Deletion of information from database. DDL – DATA DEFINATION LANGUAGE The SQL sentences that are used to create these objects are called DDL’s or Data Definition Language. These are more commonly used in commercial applications. Oracle client tools are also called front end.  Modification of data stored in database. It is language that enables users to access or manipulate data as organized by appropriate data model. Client tools are more useful in commercial application development. Following are the various DDL commands are  Alter table & Create table & drop table  Create index & drop index  Create view & drop view DML – DATA MANIPULATION LANGUAGE The SQL sentences used to manipulate data within these objects are called DML’s or Data Manipulation Language. Manages the data sharing  Accepts the query statements PL/SQL and SQL  Enforce the transaction consistency ORACLE CLIENT TOOL Once Oracle engine is loaded into sever memory user would have to log in to engine in order to work done.

It is language used to control data and access to the database.  Delete Insert DCL – DATA CONTROL LANGUAGE The SQL sentences. are called DCL’s or Data Control Language. which are used to control the behavior of these objects. Following are some DCL commands are  Commit  Rollback  Save point  Set transaction DATA TYPES OF SQL ***** 7 ***** .

i.e. To enter dates other than the standard format. By default. Syntax is LONG (SIZE) Example is LONG (20) values cannot be indexed. Numbers as large as 9. The precision. S) Example is NUMBER (10. (S). The standard format id DD- MM-YY as in 13-JUL-85. The maximum number of characters (i. The  maximum this data type can hold is 4000 characters. whereas the scale. Date Time stores date in the 24-hour format. (P). LONG  up to 2GB.e. determines the maximum length of the data. Syntax is DATE LONG RAW : LONG RAW data types are used to store binary data. 2) LONG : This data type is used to store variable length character strings containing ASCII format. the time in a date field is 12:00:00 am. One difference between this data type and the CHAR data type is ORACLE compares VARCHAR values using non-padded comparison semantics i.99 * 10 to the power of 124. If precision is omitted values are stored with their original precision up to the maximum of 38 digits. LONG data can be used to store arrays of binary data in to LONG values. such as  ***** 8 ***** . use the appropriate functions.e. Syntax is NUMBER (P. the size) this data type can hold is 255 characters.  Numbers of virtually any magnitude maybe stored up to 38 digits of precision. CHAR : This data type is used to store character strings values of fixed length. The size in brackets determines the number of characters the cell can hold. followed by 125 zeros can be stored. if no time portion is specified. The default date for a date field is the first day of the current month. Syntax is CHAR(SIZE) Example is CHAR (20) VARCHAR : This data type is used to store variable length alphanumeric data. determines the number of places to the right of the decimal. Syntax is VARCHAR(SIZE) Example is VARCHAR (20) OR VARCHAR2 (20) NUMBER : The NUMBER data type is used to store numbers (fixed or floating point). If scale is omitted then the default is zero. the inserted values will not be padded with spaces. and the normal character functions such as SUBSTR cannot be applied  DATE : This data type is used to represent data and time.

It ends the transaction but undoes any changes made during the transaction. An active save point is one that is specified since the last COMMIT or ROLLBACK. as far as the specified save point. Syntax is RAW(SIZE) TRANSACTION STATEMENTS  COMMIT: A COMMIT ends the current transaction and makes permanent any changes made during the transaction. ***** 9 ***** . Values stored in columns having LONG RAW data type cannot be indexed. Where Work is optional and comment text is used to specify comment  ROLLBACK : A ROLLBACK does exactly the opposite of COMMIT. Syntax is SAVEPOINT savepointname. Data type can have a maximum length of 255 bytes. Syntax is LONGRAW (SIZE)  RAW : It is used to hold strings of byte oriented data. Data loaded into columns of these data types are stored without any further conversion. SAVEPOINT is optional and is used to rollback a partial transaction. LONG RAW data type can contain up to 2GB. parts of a transaction can be undone. When a SAVEPOINT is used with a ROLLBACK statement. Where Save point is an identifier and it is not to declared in declare section. Syntax is ROLLBACK [WORK] [TO [SAVEPOINT] save point] Where WORK is optional and is provided for ANSI compatibility.Digitized picture or image. Syntax is COMMIT [work] [comment text]. All transactional locks acquired on tables are released.  SAVEPOINT : SAVEPOINT marks and saves the current point in the processing of a transaction. All transactional locks acquired on tables are released. SAVEPOINT is a save point created during the current transaction.

To create a table we will name the table and the columns of the table.SQL COMMANDS  CREATE TABLE: A table is basic unit of storage.  It must not be duplicate and not any reserved word. It is composed of rows and columns. We follow the rules to name tables and columns: It must begin with a letter and can be up to 30 characters long. ***** 10 ***** .

Example is SELECT empno. column_name2 datatype (size) …). sal from emp. Example is CREATE TABLE student (rollno number (4). ename.Syntax to create a table is CREATE TABLE tablename (column_name1 datatype (size).  SELECT : The select command of sql lets you make queries on the database.col2 datatype). Syntax to add a column is ALTER TABLE tablename ADD(col1 datatype. Syntax to drop table is DROP TABLE tablename ***** 11 ***** .  DROP TABLE : To remove the definition of oracle table. A query is a command that is given certain specified information from the database tables.  ALTER TABLE : After creating a table one may have need to change the table either by add new columns or by modify existing columns. Example is CREATE TABLE stud(empno.ename. name varchar2 (15)).<column2>. It will create the table as well as insert the rows returned from subquery.ename.……) AS SELECT <column1>.<column2> FROM <tablename>.<column_name2> FROM <tablename>.salary) AS SELECT empno. the drop table statement is used. Syntax to modify a column is ALTER TABLE tablename MODIFY(col1 datatype. It can be used to retrieve a subset of rows or columns from one or more tables.col2 datatype).sal FROM emp. Syntax to create table from another table is CREATE TABLE tablename(<column1>. Syntax to create a table is SELECT <column_name1>.  CREATE TABLE FROM ANOTHER TABLE : We can create a table by applying as subquery clause from another clause. One can do so by using alter table command.

 RENAME : One can change the name of a table by rename command Syntax to rename table is RENAME oldname TO newname  DELETE : One can delete data fron table by using delete from statement.value2. Syntax is ***** 12 ***** .  DISTINCT CLAUSE : The distinct keyword duplicates all rows from results of a select statement. Syntax of delete rows from table is DELETE FROM tablename WHERE <condition>. their data types and other attributes of a table we can use DESCRIBE command.55000).’MOHIT’.value3).  WHERE CLAUSE : The where clause specifies the criteria for selection of rows to be returned.col2=value2. Example is SELECT DISTINCT job FROM emp.<cols2> FROM tablename.  DESCRIBE : To find information about columns like column name.basic_pay) VALUES(100001. Example is INSERT INTO employee(emp_id. Syntax to describe table is DESCRIBE tablename. Syntax to update value of table is UPDATE tablename SET col1=value1.  INSERT : To add new rows in an existing oracle table the insert command is used. Syntax to remove distinct rows is SELECT DISTINCT <col1>. Example is UPDATE emp_info SET salary =salary +100.desg. Syntax to add new fields is INSERT INTO tablename(col1.col2.) VALUES(value1.col3.  UPDATE : The update command enables user to change the values of existing rows...’MANAGER’.ename. The delete statement removes rows from table but it doesn’t release storage space.

Example is SELECT deptt. ***** 13 ***** .avg(salary) FROM emp_infoGROUP BY deptt.col2.col3.col2 FROM tablename GROUP BY <col>. Syntax is SELECT <col1>.value2. Syntax is SELECT col1.  IN: In operator is used to check a value as search from a domain of multiple values to perform a query.sal FROM emp WHERE sal > 2000.<col2> FROM tablename WHERE <col> IN (value1.<col2> FROM tablename WHERE <cond>. Not In acts as reverse of In. Syntax is SELECT col1.  HAVING CLAUSE : The having clause filters the group values created by group by clause. This clause can precede the group by clause but it is more logical if we place group by first. Example is SELECT deptt.max(salary) FROM emp_info GROUP BY deptt HAVING max(salary) > 12000. It can be done either in ascending or descending.  GROUP BY CLAUSE : The group clause is sued in select statement to divide the table into groups.value3). It allows sorting of query results by one or more columns. Syntax to sort result of query is SELECT * FROM tablename ORDER BY col1.col2 FROM tablename GROUP BY <col> HAVING <condition>.  ORDER BY CLAUSE : You can sort the results of query ina specific order using order by clause. Example is SELECT ename. Example is SELECT * FROM emp ORDER BY ename desc.SELECT <col1>. Grouping can be done by column name or wih aggregate functions in which case the aggregate producing a value for each group.

’english’). The types of set operators are: UNION : The union clause merges the outputs of multiple queries into a single set of rows and columns. Syntax is SELECT <statement> UNION SELECT <statements>.<column2> FROM <tablename>.’electronics’. It consumes two or more queries into one result. SET OPERATORS Set keywords are used to combine information of similar type from one or more than one table. It combines rows returned by two select statements by eliminating duplicate rows. All is essentially a clarifier rather than a functional argument. ***** 14 ***** . Syntax is SELECT ALL <column1>.city. Set operations and the operators are based on set theory.state FROM employee WHERE deptt IN (‘comp’. Example is SELECT designation FROM emp_info WHERE deptt=’comp’ UNION SELECT designation FROM emp_info WHERE deptt=’eco’.Example is SELECT ename. Syntax is SELECT <statement> INTERSECT SELECT <statements>.  ALL : It retains duplicate output rows.address. Example is SELECT ALL city FROM suppliers. Example is SELECT designation FROM emp_info WHERE deptt=’comp’ INTERSECT SELECT designation FROM emp_info WHERE deptt=’eco’. INTERSECT : The intersect operator combines two select statements and return only  those rows that are returned by both queries.

Syntax is SELECT <statement> MINUS SELECT <statements>. The command for creating view is CREATE VIEW command. It is virtual table & does not have any data of its own. A view contains data of its own. Example is SELECT desgination FROM emp_info WHERE deptt=’comp’ MINUS SELECT desgination FROM emp_info WHERE deptt=’eco’. MINUS : It combines the result of two queries and returns only those values that are selected by first query but not in second query. Syntax to create a view is ***** 15 ***** . ENHANCING PERFORMANCE Views : A view is very commonly used database object that is derived at runtime. Its contents are derived from another table. Editing in the tables are automatically reflected in the views.

dept WHERE emp. Two types are Read only and update. It is defined as copy of part of table or entire table. sal. A sequence can be defined to    generate numbers in ascending or descending order.Oracle also offers an inline view that is very handy and inline view is part of SQL statements. distinct. Read-only does not allow changes to be made in view.deptno = dept. provide intervals between numbers. Syntax is CREATE OR REPLACE VIEW mohit AS SELECT ename. aggregation. aggregate functions  Distinct operator . insert and delete command to change data in table. This type of view allows update. Types of views are as follows:  Join View:. rownum pseudo columns  Group by clause . Caching of sequence numbers in memory.CREATE [OR REPLACE] VIEW view name AS sub query [WITH CHECK OPTION] [WITH READ ONLY].It is defined as view that has more than one table specified in from clause and does not contain following clauses i. Sequences : Oracle provides an object called a Sequence that can generate numeric values. The value generated can have a maximum of 38 digits. empno. It allows changes in local copy which periodically updates master table. Example is CREATE VIEW mohit AS SELECT empno.Snapshot also called materialized view.e. It reflects the current status of table that is being copied. It allows you in body of SQL statement to define SQL for view that SQL statement will use to resolve its query. The original status table is also called master table.deptno. having clause  Inline View: . group by. The views to be updateable must not include the following are  Set operators .  Materialized View: . Syntax is CREATE SEQUENCE sequence name [INCREMENT BY integervalue START WITH integervalue ***** 16 ***** . A sequence is a database object used to generate unique integers for use as primary keys. ename. It simply publishes and subscribes the replications. comm FROM emp. sal FROM emp.

Oracle retrieves rows in table in one of two ways are:  By ROWID  By full table scan The creation and dropping of index doesn’t affect the storage of data in the underlying tables. The types of indexes are: UNIQUE : It doesn’t allow duplicate values for indexed columns.  DUPLICATE : It allows duplicate values for indexed columns. Indexes are primarily used for 2 reasons are:  To ensure the uniqueness of the indexed column’s values. Example is ***** 17 ***** . Indexes : Index is a way to store and search records in the table. These are used to improve the speed with which records can be located and retrieved from the table. Example is CREATE UNIQUE INDEX mohit ON EMP (ename). Syntax to create an index is CREATE INDEX <index name> ON <tablename>(column name).MAXVALUE integervalue / NOMAXVALUE MINVALUE integervalue / NOMINVALUE CYCLE / NOCYCLE CACHE integervalue / NOCACHE ORDER / NOORDER] Example is CREATE SEQUENCE mohit INCREMENT BY 1 START WITH 1 MINVALUE 1 MAXVALUE 9999 CYCLE.  To enhance performance. Syntax to drop an index is DROP INDEX <index name>.

GRANTING AND REVOKING PERMISSIONS  GRANT : The Grant statement provides various types of access to database objects such as tables. Example is CREATE UNIQUE INDEX mohit ON EMP (ename.  FUNCTIONAL : perform some functions on fields and then indexes it. A privilege is consent to execute an action or to access another user object. These consents can be given by grant statement. Syntax is GRANT {object privileges} ON object name TO username [WITH GRANT OPTION].CREATE DUPLICATE INDEX mohit ON EMP (ename). ***** 18 ***** . sal). views and sequences. Example is CREATE INDEX mohit ON EMP (sal+100).  COMPOSITE : multi column indexes. The WITH GRANT OPTION allows the grantee to in turn grant object privileges to other users.

The REVOKE statement is used to deny the grant given on an object. INSERT allows the grantee to add records to the table with the INSERT Command. INSERT ON item TO mohit. allows the grantee to create an index on the table with the CREATE INDEX command. has the power to REVOKE the privileges from a grantee. SELECT allows the grantee to query the table with the SELECT Command. Syntax is REVOKE {object privileges} ON object name ***** 19 ***** . GRANT SELECT. UPDATE allows the grantee to modify the records in the tables with the UPDATE command. DELETE INDEX allows the grantee to remove the records from the table with the DELETE command. ALTER allows the grantee to change the table definition with the. Example to grant select & insert privileges on table item to user named as mohit. ALTER TABLE command. but has been granted the GRANT privilege. The object owner can revoke privileges granted to another user. The user can grant all the privileges or grant only specific object privileges.Object privileges Each object privileges that is granted authorizes the grantee to Perform some operation on the object. A user of an object who is not the owner.  REVOKE : Privileges once given can be denied to a user using the REVOKE command. GRANT ALL ON EMP TO mohit. Example to grant all privileges on table EMP to user named as chiku.

Syntax is SELECT <col1>. deptt. PATTERN MATCHING SQL includes string matching operator LIKE for comparison on character string using patterns. Example to revoke all privileges on table EMP to user named as chiku. REVOKE SELECT. Example to revoke select & insert privileges on table item to user named as mohit. Example is SELECT empname. To get a range of values from a query. The patterns are case sensitive and that is uppercase letters do not match lower case characters. This is achieved by using wildcard characters. ***** 20 ***** . you may use between operators. INSERT ON item TO mohit. which is not identical.<col2> FROM table name WHERE <col> BETWEEN lower limit and upper limit. The LIKE predicate allows for a comparison of one string with another string value. RANGE SEARCHING BETWEEN operator acts as range searching operator. You must specify the lower and upper limit for range search. SELECT * FROM EMP WHERE ename LIKE ‘MOH__’. REVOKE ALL ON EMP TO mohit. The keyword NOT LIKE is used to select those rows that do not match the specified pattern of characters. Two wildcard characters that are available are: For character data types: The percent sign (%) matches any string The Underscore (_) matches any single character Example is SELECT * FROM EMP WHERE ename LIKE ‘_B%’. basic pay FROM employee WHERE basic pay BETWEEN 5000 and 10000.FROM username.

Syntax is SELECT “list of columns” FROM table1. If join condition is omitted then the result is Cartesian product. Syntax is SELECTfield1. Types of joins are  Equi join : It returns all rows from tables where there is a match.field2 FROM table1. table2 WHERE “condition”. It is also known as equality join or simple join or inner join.table2 WHERE table1. This join condition is based on primary keys and foreign keys. Tables are joined on columns that have the same datatype & size in table. ***** 21 ***** . There must be n-1 join conditions for n joins to tables.JOINS A JOIN can be recognized in sql select statement if its has more than one table after from keyword.field=table2.field.

SUBQUERIES A sub query is a form of an SQL statement that appears inside another SQL statement.  Self Join : The self join can be seen as join of two copies of the same table. We can forcefully select those rows by outer join.deptno. Example is SELECT e.col. The parent statement uses the rows returned by the sub query.empno. field2 FROM table1. dept. All the rows are joined to all rows of the second table. dname FROM emp. dept WHERE emp.col. It is also termed as nested query.ename FROM emp e. The statement containing a sub query is called a parent statement.  Cartesion join : When the join condition is omitted the result is Cartesian join of two or more tables in which all the combinations of rows will be displayed.deptno (+) = dept. ename.deptno. emp m WHERE e. Syntax is SELECT table1. dname FROM emp. The table is not actually copied but sql performs the command as though it were. Example is SELECTename.mgr=e.  To create tables and insert records in the table created. table2 WHERE table1.deptno=dept. Example is SELECT empno.col FROM table1. It can be used by the following commands:  To insert records in a target table. m. Syntax is SELECT field1. The rows for those columns will have NULL values.  To create views.ename. table2.deptno.col (+) = table2.Example is SELECTename.  Outer join : While using equi join we see that if there exists certain rows in one table which don’t have corresponding values in the second table thn those rows will not be selected.  To update records in a target table. emp. dept WHERE emp. table2. ***** 22 ***** . dname FROM emp.

Table level constraint : Table constraints is specified at end of create table statement to constraint more than one column. rather than building similar logic in individual applicati Column level constraint Table level constraint Constraints can constrain single column or group of columns in a table. IN etc. Multiple row : Subqueries that return more than one row called multiple row queries.deptno FROM emp WHERE sal IN (SELECT min(sal) FROM emp GROUP BY deptno).qty FROM item WHERE ordid = 605 AND ordid <> 605). HAVING. Multiple column : It returns more than one column . Example is SELECT ename. qty FROM item WHERE (qty. ***** 23 ***** . Types of sub queries are Single row : It returns one row from inner nested query. UPDATE. Example is  SELECT deptno FROM emp WHERE ename =’MILLER’.ALL. To provide values for conditions in WHERE. It helps in maintaining integrity of table at database level instead of application level.ANY are used. All applicat can take advantage of these global constraints. CONSTRAINTS Constraints are the rules that restrict the data values inserted in columns of a table. Constraints can be specified as two typ   Column level constraint : Column constraints are specified as part of column definition to constrain single column.Example is  SELECT ordid . and DELETE statements.sal. used with SELECT.  Operators like IN.prodid) IN (SELECT prodid. prodid .

More than one Null value can be inserted in the column.at column level -.PRIMARY KEY(dept)). Syntax is COLUMN_NAME DATA_TYPE(SIZE) UNIQUE UNIQUE COLUMN_NAME DATA_TYPE(SIZE) Example is CREATE TABLE dept(deptt varchar2(25) UNIQUE). CREATE TABLE dept(deptt varchar2(25). Syntax is COLUMN DATA_TYPE(SIZE) PRIMARY KEY -.  PRIMARY KEY : Primary key refers to one or more column values in a table that can uniquely identify each row in a table.  FOREIGN KEY : A foreign key is a one or more column with values based on the primary key values from another table. A primary key column cannot contain nulls and is unique by default. CREATE TABLE dept(deptt varchar2(25). Syntax is COLUMN_NAME DATA_TYPE(SIZE) NOT NULL Example is CREATE TABLE employee(empname varchar2(25) NOT NULL) . Absence of a value in a column. Values in field cannot be duplicated.UNIQUE(dept)).Following are the constraints used in tables are  NULL/NOT NULL : Specifies if the column must contain value or might not contain any.at table level ***** 24 ***** .at table level Example is CREATE TABLE dept(deptt varchar2(25) PRIMARY KEY). The table containing foreign key is known as Dependent table and the table that is referenced by foreign key is called Referenced table. A foreign key constraint specifies that the values stored in foreign column correspond to values of the primary key in the other table.at column level -.  UNIQUE : Specifies that all values in a column must be unique. Syntax is COLUMN DATA_TYPE(SIZE) REFERENCES TABLE -. ie. NOT NULL specifies that all rows in the table to have value for specified column. Unique constraint can be placed on multiple columns. All NOT NULL columns are mandatory fields. By default all columns in a table allows nulls.at column level PRIMARY KEY COLUMN DATA_TYPE(SIZE) -. Foreign key is also known as referential integrity constraint.

***** 25 ***** . CREATE TABLE dept(deptt varchar2(25). Example is select ascii(‘b’)from dual.PRIMARY KEY(dept) FOREIGN KEY(dept) REFERENCES emp_info). FUNCTIONS Functions make the result of the query easier and are used to manipulate the data values.FOREIGN KEY COLUMN DATA_TYPE(SIZE) REFERENCES TABLE Example is CREATE TABLE dept(deptt varchar2(25) REFERENCES emp_info). Following are the functions are   String or character functions Number functions Aggregate functions or group functions Date functions Conversion functions    Character Manipulation functions  Ascii : It returns the ASCII decimal equivalent of a character passed as an argument.

12.c2. so that  the total width becomes equal to the value n. Example is select char (97) from dual. ***** 26 ***** .’S’) from dept. Ltrim : It removes all the blank spaces from the left side of the stringif no char is specified. length : It returns the length of the string x. Examples select concat(‘mohit’.’*’) from dept. it pads the char1 on the left side with blank spaces to the total width of n.’up’. If char2 is absent.  Example is select length (‘mohit’) from dual.’o’) from dual. then it removes the leading occurrences of that charcter from the string. instr :This function returns the first position of the character x in the string. Rtrim : This function removes all the blank spaces from the right side if no char is  specified. Rpad : This function pads the leading spaces to the right side of the column char1 with the  char2. Replace : Where c1.’*’)from dept. Example is select rtrim(dname.  Example is select instr(‘mohit’.x2) : This function concates the string x1 with x2.down’)from dual. the default value of c3 is NULL.c3 and c3 are all character string . Chr : This function gives the result as a character corresponding to the value in the database set. so that the total width becomes equl to the value n. lpad : It pads the leading spaces to the left side of the column char1 with the char2.this function returns c1 with all  occurenes of c2 replaced with c3.’S’) from dept. Example is select lpad(dname. Example is select rpad(dname. concat(x1. This function is equivalent  to the | | operator. Example is select ltrim(dname. Example is select replace (uptown.12.  If we give a char.’garg’)from dual.

Syntax is avg([distinct|all]column name) Example is select avg(sal).  Example is select upper(dname)from dept. Group functions  Count : This function returns the number of rows or non-null values for column x.  Example is select initcap (dname) from dept.  Min : This function returns the minimum of values for the column x for all the rows. Example is  select dname. Syntax is sum([distinct|all]column name) Example is select sum(sal) from emp. of length equal to y starting at position x .2) from dept. Initcap : This function returns the string with letter in caps.count(sal) from emp. Translate : This function is used to find a char and replace it with new character. Upper : It converts the string into upper case. This function is applied on columns having numeric datatype and it returns the numeric value.’E’. Lower : This function converts the string into lower case.  Sum : This function ireturns the sum of values for the column x. ***** 27 ***** . Syntax is min([distinct|all]column name) Example is select min(sal) from emp.5) from dual. Example is select substr(‘mohitgarg’2. It ignores the null values in the column x. Syntax is count([distinct|all]column name) Example is select count(empno)from emp. Substr : It returns the substring from z.  Avg : Ths function returns the average of values for the column x. translate (dname.  Example is select lower (dname)from dept.

3).  Mod : It returns the remainder when x is divided by the number y. Example is select power (2.8).mod (10.max(sal) from emp. Example is Select abs(-10) from dual. Example is select mod (10. Example is select exp (4) from dual. Syntax is max([distinct|all]column name) Example is select min(sal). Example is select ceil (9.  Ceil : Where is a number.  Floor : This function returns the largest integer that is less than or equal to n. ceil (-32. 3) from dual. Number functions  Abs : It obtains the absolute value for the number x.85) from dual.8).5)from dual.  Cos : It returns trigonometric cosine of the number n.85) from dual. Example is select cos(45) from dual. Example is select floor (9. floor (-32.  Power : This function returns the value of x raised to the power of y. This function returns the smallest integer that is greater than or equal to n. ***** 28 ***** .  Exp : It returns the e raised to the x power. The argument y should be an integer. Max : This function returns the maximum of values for the column x for all the rows.

Syntax is LAST_DAY(d) where d is date Example is select last_day(sysdate) from dual. round(55. Example is select sign (-2) from dual.2) from dual. Round : It rounds off x to the decimal precision of y. Example is select round (55. ***** 29 ***** .  Months_between : It computes & returns the number of months b/w two dates.m) where date refers to date & m is number value. Date functions  Add_months : It adds the months in specified date with the function. Example is select sqrt(36) from dual. Example is select add_months(sysdate.1 ).  Last_day : It returns the last day of given month which is specified with function.  Sign : This function returns the sign of the value x.  Sqrt : This function returns the square root of the given number x. If x is a negative number it returns -1 otherwise it returns 1. Syntax is MONTHS_BETWEEN(date1. Syntax is ADD_MONTHS(date.date2) Example is select months_between(’13-mar-05’.849. rounds to the precision of y places to the left of the decimal point.849) from dual.’01-dec-05’) from dual. If y is negative.

Syntax is NEXT_DAY(date. Example is select next_day(’13mar-05’. ***** 30 ***** .’sunday’) from dual.ch) where ch refers to character value. Next_day : It returns the date of first day of the week specified in a string after the beginning date.

Sign up to vote on this title
UsefulNot useful