Dbms Practicals
Dbms Practicals
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.
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, 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
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 Oracle
It is a nonprocedural language.
It reduces the amount of time required for creating and maintaining systems.
It is English like language.
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 Definition Language):-It is a set of SQL commands used to
create, modify and delete database structures but not data. They are normally used
by the DBA not by user to a limited extent, 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 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.
5) TCL commands can only use with DML commands like INSERT, DELETE and UPDATE
only.
These operations are automatically committed in the database that’s why they cannot
be used while creating tables or dropping them.
CHAR
VARCHAR (size) or VARChAR2 (size)
NUMBER
DATE
LONG.
CHAR: -This data types is used to store character strings values of fixed
length. The size in brackets determines the number of characters the cell
can hold. The maximum number of characters (i.e. the size) this data
type can hold is 255 characters. The data held is right- padded with
spaces to whatever length specified.
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
The use of LONG values is subject to some restrictions:
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 TABLE COMMAND :- 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).
Example:
Table created.
2) THE INSERTION OF DATA INTO TABLE: - 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 <table name >(<columnname1>,<columnname2>)
VALUES(<expression1>,<expression 2>);
OR
OR
Example:-
SQL> insert
intostudent(name,roll_no,class,address)values(‘Prabhat’,06,’BCA’,
Hatlimore’);
1 row created.
Or
1 row created.
Or
1 row created.
FOR inserting more values we use ‘/’ slash after SQL> as below but after
above syntax used:
SQL> /
1 row created.
3) FOR VIEWING DATA IN THE 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 <table name>;
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;
1 row created.
When we use the command SELECT* FRM TAB;the output is displayed as:-
SQL> select * from tab;
NAME ROLL_NO
-------------------- ----------
Prabhat06
6 rows selected
Vinay 08 BCAbarnoti
Prabhat 06 BCAHatlimore
Kishore01 BCANagri
Dushyant34 BCAjagatpur
Atinder04 BCAsawanchakAmarjeet 30 BCA
airwan
6 rows selected.
Kishore01 BCANagri
Atinder04 BCAsawanchak
Prabhat 06 BCAHatlimore
Vinay 08 BCAbarnoti
Amarjeet 30 BCA airwan
Dushyant34 BCAjagatpur
6 rows selected.
Table renamed.
8) DESTROYING TABLES:-
DROP COMMAND: - By using the DROP TABLE statement with the table name we can
destroy a specific table .
Syntax: -DROP TABLE <table name>;
Example:--
10) UPDATING THE CONTENTS OF A TABLE: - The update command is used to change
or modify data values in a table. The verb UPDATE in SQL is used to either 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 WHERE CLAUSE specifies which rows should
be updated. Otherwise all table rows are updated.
Syntax: -UPDATE < Table name> SET <column name1>=<expression1> ,<column
name2>=<expression2>;
Eg:- Update student set course=’bca’ ;
Connect to the database server. You can find the Oracle version by issuing a
simple SQL statement.
Press ↵ Enter
The Oracle version number appears next to ″Oracle Database″ in the first
line of the result.
Example:-