26812648 Practical File SQL Queries DBMS

January 29, 2019 | Author: swathirohith | Category: Sql, Databases, Table (Database), Oracle Database, Data Management
Share Embed Donate


Short Description

Download 26812648 Practical File SQL Queries DBMS...

Description

1 DBMS & SQL queries

DBMS & SQL Queries Session -10

-

2009

Submitted by:

Submitted to:

Name: Prabhat Kumar

Kanika Mahajan

Class: BCA IInd

Concerned Lect. in DBMS

Class Roll no . 06

Ashoka college of Computer

Ashoka College of Computer Education |

2 DBMS & SQL queries

Certificate  This  This is certi certifie fied d tha thatt the the practical practical file belongs belongs to Prabhat Kumar, Class roll no. 06 and Examination Roll no…………of session 2009-10 and has completed all the practical in the college computer lab under our guidance and his behavior in the college is good. Ashoka College of Computer Education |

3 DBMS & SQL queries

Teacher Incharge Principal

Index

Ashoka College of Computer Education |

4 DBMS & SQL queries

S. no. 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25.

Name of practical

Remarks

Database, DBMS definition Introduction to SQL Components of SQL, Data types SQL Queries create, insertion Create a table Describe the table Insert the values To view the table Sorting the data To rename the table Delete a particular row Lower case Upper case Drop the table Maximum Minimum Average Like Between Primary key Unique key Count Sum Alter Update

Ashoka College of Computer Education |

5 DBMS & SQL queries

Database A database is an organized collection of facts. In other words, we can say that it is a collection of information arranged and presented to serve an assigned purpose. An example of a database is a dictionary

Database Management System Database management system, or DBMS, is a computer software program that is designed as the means of managing all databases that are currently installed on a system hard drive or network. Different types of database management systems exist, with some of them designed for the oversight and proper control of  databases that are configured for specific purposes. Here are Ashoka College of Computer Education |

6 DBMS & SQL queries

some examples of the various incarnations of DBMS technology that are currently in use, and some of the basic elements elements that are part of DBMS software applications. As the tool that is employed in the broad practice of managing databases, the DBMS is marketed in many forms. Some of the more popular examples of DBMS solutions include Microsoft Access, FileMaker, FileMaker, DB2, and Oracle. All these products provide for the creation of a series of rights or privileges that can be associated with a specific user. This means that it is possible to designate one or more database administrators who may control each function, as well as provide other users with various levels of  administration administration rights. This flexibility makes the task of using DBMS methods to oversee a system something that can be centrally controlled, or allocated to several different people.

Introduction to Structured Query Language (SQL) Structured query language is a language that provides an interface to relational database systems. SQL was developed by IBM in the 1970s for use in system R, and is a de facto standard, as well as an ISO and ANSI standard. SQL is often pronounced SEQUEL. SQL has been a command language for communication with the oracle 9i server from any tool or application. Oracle SQL contains many extensions. When an SQL statement is entered, it is stored in a part of memory called the SQL buffer and remains there until a new SQL statement is entered.

Ashoka College of Computer Education |

7 DBMS & SQL queries

Features of Structured query language (SQL) SQL can be used by a range of users, including those with little or no programming experience. •





It is a nonprocedural language. It reduces the amount of time required for creating and maintaining systems. It is English like language.

Components of SQL

1)

DDL (Data Definiti Defi nition on Language) Langu age) :- It is a set of SQL commands used to create, modify and delete database structures but not data.  They are normall normally y used by the the DBA not by user to to a limited limited exten extent, t, a database designer or application developer. These statements are immediate i.e. they are not susceptible to ROLLBACK commands. It should also be noted that if several DML statements for example UPDATES are executed then issuing any a ny DDL command would COMMIT all the updates as every DDL command implicitly issues a COMMIT command to the database. Anybody using DDL must have the CREATE object privilege and a table space area in which to create objects. For example: - CREATE, ALTER, DROP, TRUNCATE, COMMENT etc.

2)

DML (Data (Dat a Manipulat Manip ulation ion Language) Langu age)::- It is the area of SQL that allows changing data within the database. Examples:-INSERT, UPDATE, DELETE etc.

Ashoka College of Computer Education |

8 DBMS & SQL queries 3)

DCL (Data (Dat a Control Contr ol Language): Langua ge):-- It is the component of SQL statement that control access to data and to the database. Occasionally DCL statements are grouped with DML statements. Examples: - COMMIT, SAVEPOINT, S AVEPOINT, ROLLBACK ROLLBACK etc.

4)

DQL (Data (Dat a Query Quer y Language): Langua ge):-- It is the component of SQL statement that allows getting data from the database and imposing ordering upon it. It includes the SELECT statement. This command is the heart of SQL. It allows getting the data out of the database perform operations with it. When a SELECT is fired against a table or tables the results is compiled into a further temporary table, which is displayed or perhaps received by the program i.e. a front-end. Examples: - SELECT retrieve data from the database.

Oracle data types Data types come in several forms and sizes, allowing the programmer to create tables suited to the scope of the project. The decisions made in choosing proper data types greatly influence the performance of a database.  The informa information tion in the database database is maintaine maintained d in the the form of tables tables and each table consists of rows and columns, which store data and therefore this data must have some data type i.e. the type of data, which is stored in the table.  The differen differentt types types of data types types in Oracle Oracle are:•

CHAR



VARCHAR (size) or VARChAR2 (size)



NUMBER



DATE



LONG.



data types types is used used to store character character strings strings CHAR: - This data values of fixed length. The size in brackets determines the number of characters the cell can hold. The T he maximum number of characters (i.e. the size) this data type can hold is 255 Ashoka College of Computer Education |

9 DBMS & SQL queries

characters. The data held is right- padded with spaces to whatever length specified.



data type type is used used to store VARCHAR or VARCHAR2:- This data variable length alphanumeric data. It is a more flexible form of  the CHAR data type. The maximum this data type can hold up to 4000 characters. One difference between this data type and char data type is oracle compares varchar values using non padded comparison semantics i.e. the inserted values will not be padded with spaces. VARCHAR can hold 1 to 255 characters. Varchar is usually a wiser choice than char due to its variable length format characteristics but keep in mind that char is much faster than varchar sometimes up to 50%.



NUMBER: - The number number data data type type is used used to store numbers numbers (fixed or floating point).The precision (P) determines the length of the data while(s), the scale, determines the number of  places after the decimal. The NUMBER data type that is used to store number data can be specified either to store integers or decimals with the addition of a parenthetical precision indicator. If we do not use then the default value is 0 and if we don’t use precision then by default value stored can be of 38 digits.



DATE:- The DATE data type stores date and time information. Although date and time information can be represented in both character and number data types, the DATE data type has special associated properties. For each DATE value, Oracle stores the following information: century, year, month, date, hour, minute, and second.



LONG:- LONG columns store variable-length character strings containing up to 2 gigabytes, or 231-1 bytes. LONG columns have many of the characteristics of VARCHAR2 columns. You can use LONG columns to store long text strings. The length of  LONG values may be limited by the memory available on your computer Ashoka College of Computer Education |

10 DBMS & SQL queries

 The use use of LONG LONG values values is subject subject to some some restric restrictions tions:: • • •

• • •



A table can contain only one LONG column.  You cannot cannot create an object object type type with with a LONG LONG attribut attribute. e. LONG columns cannot appear in WHERE clauses or in integrity constraints (except that they can appear in NULL and NOT NULL constraints). LONG columns cannot be indexed. A stored function cannot return a LONG value.  You can can declare declare a variable variable or argument argument of a PL/SQL PL/SQL program program unit using using the LONG datatype. However, you cannot then call the program unit from SQL. Within a single SQL statement, all LONG columns, updated tables, and locked tables must be located on the same database.

QUERY  A query is a concise memo submitted to an editor by a writer seeking publication. It is basically an in query to see whether the writer’s work is of  interest to a particular publication. A query briefly details a writer’s experience and knowledge of the subject matter, and gives a summary or synopsis of the article the writer hopes to have published. An approximate word count for the proposed article or feature is also generally included. 1) THE CREATE CREATE TABLE TABLE COMMAN COMMAND D :- The CREATE TABLE command

defines each column of the table uniquely. Each column has a minimum of three attributes, a name, data type and size (i.e. column width). name>( (), ()); type>()); Example: SQL> create table student(name varchar(23),roll_no number(12),class number(12),class varchar2(12),address varchar2(12),address varchar(23)); varchar(23)); Table created.

2) THE INSERT INSERTION ION OF OF DATA INTO TABL TABLE: E: - Once a table is created, the

most natural thing to do is load this with data to be manipulated later i.e. to insert the rows in a table. The data in a table can be inserted in three ways. Syntax:-INSERT INTO (,) VALUES(,); Ashoka College of Computer Education |

11 DBMS & SQL queries

OR INSERT INTO VALUES(, ); OR INSERT INTO VALUES(‘’ VALUES(‘’ ,’’); Example:SQL> insert intostudent(name,roll_no,clas intostudent(name,roll_no,class,address)values( s,address)values('Prabhat',06,'BCA 'Prabhat',06,'BCA',Hat ',Hat limore'); 1 row created.

Or SQL> insert into student values('kishore',01,'BCA','Na values('kishore',01,'BCA','Nagri'); gri'); 1 row created.

Or SQL> insert into student values('&name','&roll_no','&c values('&name','&roll_no','&class','&address') lass','&address'); ; Enter value for name: Amarjeet Enter value for roll_no: 30 Enter value for class: BCA Enter value for address: airwan old 1: insert into student values('&name','&roll_no','&c values('&name','&roll_no','&class','&address') lass','&address') new 1: chack')

insert into studen values('Atinder','04','BCA', values('Atinder','04','BCA','Sawan 'Sawan

1 row created.

FOR inserting insertin g more values we use ‘/’ slash after SQL> as below but after above syntax used: SQL> / Enter value for name: Vinay

Ashoka College of Computer Education |

12 DBMS & SQL queries Enter value for roll_no: 08 Enter value for class: BCA Enter value for address: Barnoti old 1: insert into student values('&name','&roll_no','&c values('&name','&roll_no','&class','&address' lass','&address') ) new

1:

insert into studen values('Vinay','08','BCA',' values('Vinay','08','BCA','Barnoti') Barnoti')

1 row created.

3) FOR VIEWIN VIEWING G DATA DATA IN THE THE TABLE TABLE: - Once data has been inserted

into a table, the next most logical operation would be to view what has been inserted. The SELECT SQL verb is used to achieve this. The SELECT command is used to retrieve rows selected from one or more tables. Syntax: - SELECT * FROM ;

If we want to see all the tables that are already exist in the database .we use SELECT * FROM TAB; Example:SQL> select * from student;

NAME

ROLL_NO CLASS

ADDRESS

-------------------------------------------- ---------- ------------ ---------Prabhat

06 BCA

Hatlimore

Kishore

01 BCA

Nagri

Amarjeet

30 BCA

airwan

Vinay

08 BCA

barnoti

1 row created.

When we use the command SELECT* FRM TAB; the output is displayed as:Ashoka College of Computer Education |

13 DBMS & SQL queries SQL> select * from tab;

TNAME

TABTYPE

CLUSTERID

---------------------------------------------------------- ------- ---------ABC

TABLE

ANKU

TABLE

BONUS

TABLE

DEPARTMENTS

TABLE

DEPT

TABLE

EMP

TABLE

EMPLOYEE

TABLE

EMPLOYEES

TABLE

STUDENT

TABLE

9 rows selected.

4) ELIMINATI ELIMINATION ON OF OF DUPLICAT DUPLICATE E ROWS ROWS :- A table could hold duplicate

rows in unique rows the distinct clause can be used.

such a case, only

Syntax: - SELECT DISTINCT , FROM ;

 This syntax syntax will will give give the the unique unique values values of column column 1 and colum column n 2. Example:SQL> select distinct name,roll_no from student;

NAME --------------------

ROLL_NO ----------

Ashoka College of Computer Education |

14 DBMS & SQL queries Prabhat

06

Syntax:- SELECT DISTINCT * from ; Example:SQL> Select DISTINCT * from student;

NAME

ROLL_NO CLASS

----------------------------------

-------- ------------ ----------

Prabhat

06 BCA

ADDRESS

Hatlimore

5) SO SORTI RTING NG DATA DATA IN IN A TABLE TABLE: - Oracle allows data from a table to be

viewed in sorted order. The rows retrieve from the table will be sorted either in ascending or descending order depending on the condition specified in the select sentence. Syntax: - SELECT * FROM ORDER BY, ; Example:SQL> SELECT * FROM STUDENT ORDER BY name;

NAME

ROLL_NO CLASS

-------------------------------------------- ---------- ------

ADDRESS ---------------

Amarjeet

30

BCA

airwan

Atinder Dushyant

04 34

BCA BCA

sawanchak jagatpur

Kishore

01

BCA

Nagri

Prabhat

06

BCA

Hatlimore

Vinay

08

BCA

barnoti

Ashoka College of Computer Education |

15 DBMS & SQL queries 6 rows selected

SQL> SELECT*FROM STUDENT ORDER BY name desc;

NAME

ROLL_NO CLASS

ADDRESS

-------------------------------------------- ---------- ------------ --------------

Vinay

08

BCA

barnoti

Prabhat

06

BCA

Hatlimore

Kishore

01

BCA

Nagri

Dushyant

34

BCA

jagatpur

Atinder Amarjeet

04 30

BCA BCA

sawanchak airwan

6 rows selected.

SQL> SELECT * FROM STUDEN ORDER BY roll_no desc;

NAME

ROLL_NO CLASS

ADDRESS

-------------------------------------------- ---------- ------------ ---------------

Kishore

01

BCA

Nagri

Atinder

04

BCA

sawanchak

Prabhat

06

BCA

Hatlimore

Ashoka College of Computer Education |

16 DBMS & SQL queries Vinay

08

BCA

barnoti

Amarjeet

30

BCA

airwan

Dushyant

34

BCA

jagatpur

6 rows selected.

structure ure of a table 6) MODIFYIN MODIFYING G THE STRUCTU STRUCTURE RE OF TABLES TABLES: -  The struct can be modified by using the ALTER  TABLE  TABLE command. command. ALTER TABLE TABLE allows allows changing changing the the structure structure of an existing table. With ALTER TABLE it is possible to add or delete columns, create or destroy indexes, changes the data type of existing columns, or rename columns or the table itself. (a) ADDING NEW COLUMNS Syntax: - ALTER TABLE ADD( (),()….); Example:-

(b) DROPPING A COLUMN FROM A TABLE Syntax: - ALTER TABLEDROP COLUMN; Example:- alter table prabhu drop column name;

(c) MODIFYING EXISTING COLUMNS Syntax: - ALTER TABLEMODIFY( ()); Example:- alter table prabhat modify(name varchar(22));

Ashoka College of Computer Education |

17 DBMS & SQL queries 7) RENAM RENAMING ING TABLES TABLES: - Oracle allows renaming of tables. The rename

operation is done atomically, which means that no other thread can access any of the tables while the rename process is running. Syntax: - RENAME to Example:SQL> rename student to candidates;

Table renamed.

8) DESTRO DESTROYIN YING G TABLES TABLES:•

DROP COMMAND: - By using the DROP TABLE statement with the table name we can destroy a specific table . Syntax: - DROP TABLE ; Example:--

SQL> Drop table student; Table dropped.



TRUNCATE COMMAND:- The truncate command is much faster in comparison to delete

statement but similar to the drop command as to destroy a specific table. Syntax:- TRUNCATE table Example:-

SQL> truncate table employees; Table truncated.

Ashoka College of Computer Education |

18 DBMS & SQL queries 9) DISPLAYIN DISPLAYING G THE TABLE TABLE STRUCTU STRUCTURE RE:- To display information about the columns defined in a table use the following syntax. Syntax: - DESCRIBE

This command displays the columns names, the data types and a nd the special attributes connected to the table. Example: -

SQL> describe employees;

Name

Null?

Type

----------------------------------------------------------------- -------- ----------EMP_ID

NUMBER(5)

EMP_NAME

VARCHAR2(20)

DEPT_ID

NUMBER(10)

DEPT_NAME

NAME(12)

SALARY

NUMBER(21)

10) UPDATING UPDATING THE CONTE CONTENTS NTS OF A TABLE TABLE: - The update command is used to change or modify data values in a table. The verb UPDATE in SQL is used to either eit her all the rows from a table or a select set of rows from a table. UPDATING ALL ROWS:- The update statement updates columns in the existing table’s rows



with new values .The SET clause indicates which column data should be modifying and the new values that they should hold.  The WHER WHERE E CLAUSE CLAUSE specifies specifies which which rows rows should should be updated. updated. Otherwise Otherwise all table rows are updated. Syntax: - UPDATE < Table name> SET = , =;

Ashoka College of Computer Education |

19 DBMS & SQL queries



UPDATES RECORDS CONDITIONALLY ::Syntax :- UPDATE SET = , = WHERE ;

CONSTRAINTS 11) NOT NULL:- The NOT NULL column constraint ensures that a table column cannot be left

empty. When a column is defined as not null, then that t hat column becomes a mandatory column. column. It implies that a value must be entered into the column if the record is to be accepted for storage in the table. type>( ) NOT NULL ; Syntax:- () Example:-name varchar(22) not null;

THE PRIMARY KEY CONSTRAINT: - A primary is one or more column in a table

used to identify each row in a table. None of  the fields that are part of the primary key can contain a null value. A table can have only one primary Syntax:- () PRIMARY KEY Example:-

SQL> create table student name varchar2(12), roll_no number(12) primary key, class varchar2(21) NOT NULL, dob date);

or

Ashoka College of Computer Education |

20 DBMS & SQL queries SQL> create table student(name varchar2(12), roll_no number(12) constraint pk_roll primary key ,class ,class varchar2(21) varchar2(21) not null, dob date);

12) THE FO FOREIGN IGN KEY (S (SELF RE REFERENCE) CO CONSTRAINT:-Foreign key represent

relatio nships between tables. A foreign key is a column (or a group of columns) whose values are derived from the primary key or unique key of some other table. The table in which the t he foreign key is defined is called ca lled a FOREIGN  TABLE or DETAIL DETAIL TABLE. TABLE. The table that defines defines the primar primary y or or unique unique key key and is referenced by the foreign key is called the PRIMARY KEY or MASTER KEY. Fore ign key () REFERENCES REFERENCES (column name); Example:-

SQL> create table department(dept_no department(dept_no number(10) primary key,dept_name key,dept_name varchar2(25),dept_loc varchar2(25),dept_loc char(5,e_no number(11), foreign key(e_no) references employee (e_no);

Table created

SQL> describe department; Name ---------------------------------------DEPT_NO

Null? ------------NOT NULL

Type ----------NUMBER(10)

DEPT_NAME

VARCHAR2(25)

DEPT_LOC

CHAR(5)

E_NO

NUMBER(11).

Ashoka College of Computer Education |

21 DBMS & SQL queries

13) THE UNIQUE KEY CONSTRAINT:- The unique key constraint permits multiple

entries of NULL into the column. These NULL values are clubbed at the top of the column in the order in which they t hey were entered into the table. This is the essential difference between the primary key and the unique constraints when applied to table column(s). Key point about UNIQUE constraint: •

Unique key will not allow duplicate values.



Unique index is created automatically.



A table can have more than one unique key which is not possible in primary key.

Syntax:- CREATE TABLE Table name ( ( (), (),UNIQUE(, )); Example:-

SQL> create table student1(roll_no student1(roll_no number(12)primary key,dob date,name varchar2(20),class varchar2(2),e_mail varchar2(20) constraint un_st unique);

Table created.

To see the description of the table.

SQL> Describe student1;

Name

Null?

Type

---------------------------------------------------------------- -------- ----------

Ashoka College of Computer Education |

22 DBMS & SQL queries ROLL_NO

NOT NULL

NUMBER(12)

DOB

DATE

NAME

VARCHAR2(20)

CLASS

VARCHAR2(20)

E_MAIL

VARCHAR2(20)

ORACLE FUNCTIONS Oracle functions serve the purpose of manipulating data items and returning a result. Functions are the programs that take zero or more arguments and return a single value. Oracle has built a no. of functions into SQL. These functions can be called from SQL statements.

14) COUN COUNT T (expr (expr)) funct function ion: - Returns the number of rows where expression is not null. Syntax: - COUNT ([[] ) Example:-

EMP_ID NAME

DEPT_ID

SALARY

--------- -------------------- ---------- ---------1 sourabh

21

55000

2 sonu

22

55000

3 anku

4

55000

5 anku

21

55000

3 panku

22

75000

SQL> select count(distinct name) from employees;

Ashoka College of Computer Education |

23 DBMS & SQL queries COUNT(DISTINCTNAME) ------------------4

SQL> select count(salary) from employees;

COUNT(SALARY) ---------5

15) COUNT COUNT (*) functio function n: - Returns the number of rows in the table, including duplicates and those with nulls. Syntax: - COUNT(*) Example:-

SQL> select count(*) from employees;

COUNT(*) ---------5

SQL>

select count(*)"salary" count(*)"salary" from employees;

salary ---------5

Ashoka College of Computer Education |

24 DBMS & SQL queries 16) THE SU SUM M FU FUNC NCTIO TION N: - Returns the sum of the values of ‘n’. Syntax: - SUM ([][] ) Example:-

SQL> select sum (salary) from employees;

SUM(SALARY) ----------295000

17) 17) THE THE MAX MAX FUN FUNCT CTIO ION N: - Returns the maximum value of expression.

MAX([][] ) Syntax: - MAX([][] Example:-

SQL> select max(salary) from employees;

MAX(SALARY) ----------75000

18) 18) THE THE MIN MIN FUN FUNCT CTIO ION N: - Returns the minimum value of expression. Syntax: - MIN ([][] ) )

Example:SQL> select min (salary) from employees;

Ashoka College of Computer Education |

25 DBMS & SQL queries MIN(SALARY) ----------55000

19) 19) THE THE AVG AVG FUNC FUNCTIO TION N: - Returns an average value of ‘n’, ignoring null values in a column. Syntax: - AVG ([][] ); Example:-

SQL> select avg(salary) from employees;

AVG(SALARY) ----------59000

20) LIKE OPREATOR :- The LIKE predicate allows comparison of one string value with

another string value, which is not identical. This is achieved by using wildcard characters. Two wildcard characters that are available are: •



% allows to match any string of any length(including zero length)  _allows  _allows to match on a single single characte character. r.

Example:-

SQL> select emp_id,name,dept_id,salary from employees where name like 'a%';

Ashoka College of Computer Education |

26 DBMS & SQL queries EMP_ID

NAME

------



-------

DEPT_ID

SALARY

-----------

---------

3

anku

4

55000

5

anku

21

55000

NOT LIKE OPERATOR:-

Example:-

SQL>select emp_id,name,dept_id,salary emp_id,name,dept_id,salary from employees where name not like 'a%';

EMP_ID

NAME

DEPT_ID

SALARY

---------

---------------

----------

----------

1

sourabh

21

55000

2

sonu

22

55000

3

panku

22

75000

SQL>select emp_id,name,dept_id,salary emp_id,name,dept_id,salary from employees where name like '_n_u';

EMP_ID ----------

NAME ----------------

DEPT_ID SALARY ---------- ----------

3

anku

4

55000

5

anku

21

55000

Ashoka College of Computer Education |

27 DBMS & SQL queries 21) IN OPERATOR:- In case a value needs to be compared to a list of values then the IN

predicate is used. The IN predicates helps reduce the need to use multiple OR conditions. Example:-

SQL> select emp_id,name,dept_id,salary from employees where dept_id in(20,22);



EMP_ID

NAME

DEPT_ID

SALARY

----------

--------------------------------------- ----------

----------

2

sonu

22

55000

3

panku

22

75000

NOT IN OPERATOR:-

Example :SQL>select emp_id,name,dept_id,salary emp_id,name,dept_id,salary from employees where dept_id not in(20,22);

EMP_ID

NAME

DEPT_ID

SALARY

--------

--------------------

----------

----------

21

55000

22)

1

sourabh

3

anku

4

55000

5

anku

21

55000

BETWEEN OPERATOR:-

Ashoka College of Computer Education |

28 DBMS & SQL queries

SQL> select emp_id,name,dept_id,salary from employees where dept_id between 22 and 30;

EMP_ID

NAME

DEPT_ID

SALARY

---------

---------------------------------------

----------

----------

2

sonu

22

55000

3

panku

22

75000

SQL>select emp_id,name,dept_id,salary emp_id,name,dept_id,salary from employees where dept_id between 11 and 21;

EMP_ID

NAME

DEPT_ID

SALARY

---------

---------------------------------------

----------

----------

1

sourabh

21

55000

5

anku

21

55000

STRING FUNCTIONS

char, with all letters forced to 23) UPPER function :- Returns char, uppercase.

Ashoka College of Computer Education |

29 DBMS & SQL queries Syntax: - UPPER(char) Example: -

SQL> select upper(name) from employees;

UPPER(NAME) -------------------SOURABH SONU ANKU ANKU PANKU

24)

LOWER function: - Returns char, with all letters in lowercase.

Syntax: - LOWER(char) Example:-

SQL> select lower(name) from employees;

LOWER(NAME) -------------------sourabh sonu anku anku

Ashoka College of Computer Education |

30 DBMS & SQL queries panku

25) INITCAP function: - Returns a string with the first letter of  each word in upper case. Syntax:- INITCAP(char) Example:-

SQL> select initcap(name) from employees;

INITCAP(NAME) -------------------Sourabh Sonu Anku Anku Panku

Ashoka College of Computer Education |

View more...

Comments

Copyright ©2017 KUPDF Inc.
SUPPORT KUPDF