Dear readers of our blog, we'd like to recommend you to visit the main page of our website, where you can learn about our product SQLS*Plus and its advantages.
 
SQLS*Plus - best SQL Server command line reporting and automation tool! SQLS*Plus is several orders of magnitude better than SQL Server sqlcmd and osql command line tools.
 

REQUEST COMPLIMENTARY SQLS*PLUS LICENCE

Enteros UpBeat offers a patented database performance management SaaS platform. It proactively identifies root causes of complex revenue-impacting database performance issues across a growing number of RDBMS, NoSQL, and deep/machine learning database platforms. We support Oracle, SQL Server, IBM DB2, MongoDB, Casandra, MySQL, Amazon Aurora, and other database systems.

Oracle PL/SQL tutorial

27 August 2020

Oracle PL/SQL tutorial

Oracle PL/SQL is a combination of SQL, along with the procedural features of programming languages. It was developed by Oracle Corporation in the early 90’s to extend the capabilities of SQL.

PL / SQL is one of the three key programming languages built into an Oracle database, along with SQL and Java itself. This guide will give you a deep understanding of PL / SQL to continue working with the Oracle database and other advanced DBMS concepts.

Oracle PL/SQL Functions

AnalyticalSymbolic / string
ConversionNumerical / mathematical
SupportingDate / time

 

Types of Oracle requests

SELECTretrieves records from one or more tables
FROMspecifies a list of tables and any attachments
WHEREis used to filter the results
ORDER BYis used for sorting records
GROUP BYgroups the results of one or more columns
HAVINGused in combination with GROUP BY to limit groups of returned strings
DISTINCTremoves duplicates from the resulting SELECT set
EXISTSused in conjunction with a subquery
INSERTused to insert one or more records into an Oracle table
INSERT ALLis used to add multiple lines using a single INSERT operator
UPDATEused to update existing table entries in the Oracle database
DELETEused to remove one or more records from a table in Oracle
TRUNCATE TABLEis used to remove all records from the table in Oracle
UNIONremoves repetitive lines between SELECT requests
UNION ALLreturns all rows from the query and does not delete repeating rows
INTERSECTreturns the intersection of 2 sets of results
MINUSreturns one data set minus another data set
PIVOTused to rotate rows into columns
Subqueriessubqueries

 

Oracle PL/SQL programming

Data TypesData Types
LiteralsSuch as text, integer, number and datetime
Declaring VariablesAnnouncement of variables, constants
Comments within SQLSQL comments are used to comment on program code
ProceduresCreation and removal of procedures
FunctionsCreate and delete functions
TriggersCreate, delete, enable and disable triggers
Dynamic SQLDynamic SQL
PackagesPackages and package bodies – create, delete
SequencesSequences
SynonymsSynonyms
AliasesAliases (aliases) for tables or columns
WITHOperator WITH

 

Cursors (CREATE CURSOR)

Declare a Cursor

Operators

OPENFETCHCLOSE
Cursor Attributes: %FOUND, %NOTFOUND, %ISOPEN, ROWCOUNT
SELECT FOR UPDATE
WHERE CURRENT OF

 

Oracle tables and views

CREATE TABLECreate a table
CREATE TABLE ASCreate a table from the definition and data of another table
ALTER TABLEAdd, change or delete columns in the table; rename the table
DROP TABLEDelete the table (no recovery option)
GLOBAL TEMPORARY TABLESCreate a global time table
LOCAL TEMPORARY TABLESCreate a local time table
VIEWVirtual tables (views of other tables)

 

Database administration Oracle

CREATE USEROperator to create an account in the database
DROP USEROperator to delete a user from the database
ALTER USER (Change Password)Change user password in Oracle
Find Users in OracleSearch for a user in Oracle
Find Users logged into OracleSearch for users logged in to Oracle
TABLESPACETabular spaces create, modify, deleteSearch for default table spacesDefault setting of tabular spaces
Grant/Revoke PRIVILEGESProviding privileges to users in Oracle
ROLESCreating a role, granting/disabling privileges to a role, enabling/disabling a role, setting a default role and removing a role
SCHEMAThe scheme allows logical grouping of objects in an Oracle database

 

Oracle keys, indexes, unique restrictions

Primary KeysPrimary Keys
Foreign KeysExternal keys
Foreign Keys with cascade deleteExternal keys with cascading removal
Foreign Keys with set null on deleteExternal keys with “set null on delete”
Drop a foreign keyDeletion of external key
Disable a foreign keyTurn off external key
Enable a foreign keyTurning on the external key
IndexesIndexes
Unique constraintsUnique restrictions
Check constraintsChecking restrictions

 

Oracle conditional statements

IF-THEN-ELSECASEGOTO

 

Oracle cycles

 

Comparison operatorsOracle PL/SQL comparison statements such as =, !=, <>, >, >=, <, <= etc.

 

Oracle conditions

ANDlogical operator and
ORlogical operator or
AND & ORlogical operators and/or
NOTlogical operator not
LIKEcorrelates data with a template
REGEXP_LIKEuses regular expressions
INdetermines whether the value or list of values corresponds to the expression in the specified set
IS NULLNULL check
IS NOT NULLNOT NULL check
BETWEENis used to obtain values within a range

 

Oracle PL/SQL collections and records

Records

RecordRecord
%ROWTYPERecord Modifier
%TYPEColumn Modifier

Collections

Associative ArraysAssociation massifs
VarraysVariable length arrays
Nested TablesAttached Tables

 

Oracle PL/SQL collection methods

Collection methodTypeDescription
DELETEProcedureRemoves elements from the collection.
TRIMProcedureRemoves elements from the end of varray or Nested Tables.
EXTENDProcedureAdds elements to the end of varray or Nested Tables.
EXISTSFunctionReturns TRUE if and only if a certain varray or Nested Tables element exists.
FIRST & LASTFunctionsFIRST returns the first, LAST the last index in the collection.
COUNTFunctionReturns the number of items in the collection.
LIMITFunctionReturns the maximum number of items that a collection can have.
PRIOR & NEXTFunctionsPRIOR returns the index that precedes the specified index, NEXT returns the index that follows the specified index.

Oracle PL/SQL operations on collections

MULTISET UNIONReturns the merger of the two collections
MULTISET UNION DISTINCTReturns the merger of the two collections with a dystinct (removes duplicates)
MULTISET INTERSECTReturns the intersection of two collections
MULTISET INTERSECT DISTINCTReturns the intersection of the two collections with distinct (removes duplicates)
SETReturns a collection with dystinct (i.e. a collection without takes)
MULTISET EXCEPTReturns the difference (truncation) between the two collections
MULTISET EXCEPT DISTINCTReturns the difference (truncation) between two collections with distinct (removes duplicates)

 

ORACLE error

ORACLE error messages
Exception handling

 

PL/SQL Oracle tutorial, Oracle introduction, PL/SQL basics

 
Tags: , , , , , ,

MORE NEWS

 

Preamble​​NoSql is not a replacement for SQL databases but is a valid alternative for many situations where standard SQL is not the best approach for...

Preamble​​MongoDB Conditional operators specify a condition to which the value of the document field shall correspond.Comparison Query Operators $eq...

5 Database management trends impacting database administrationIn the realm of database management systems, moreover half (52%) of your competitors feel...

The data type is defined as the type of data that any column or variable can store in MS SQL Server. What is the data type? When you create any table or...

Preamble​​MS SQL Server is a client-server architecture. MS SQL Server process starts with the client application sending a query.SQL Server accepts,...

First the basics: what is the master/slave?One database server (“master”) responds and can do anything. A lot of other database servers store copies of all...

Preamble​​Atom Hopper (based on Apache Abdera) for those who may not know is an open-source project sponsored by Rackspace. Today we will figure out how to...

Preamble​​MongoDB recently introduced its new aggregation structure. This structure provides a simpler solution for calculating aggregated values rather...

FlexibilityOne of the most advertised features of MongoDB is its flexibility.  Flexibility, however, is a double-edged sword. More flexibility means more...

Preamble​​SQLShell is a cross-platform command-line tool for SQL, similar to psql for PostgreSQL or MySQL command-line tool for MySQL.Why use it?If you...

Preamble​​Writing an application on top of the framework on top of the driver on top of the database is a bit like a game on the phone: you say “insert...

Preamble​​Oracle Coherence is a distributed cache that is functionally comparable with Memcached. In addition to the basic function of the API cache, it...

Preamble​​IBM pureXML, a proprietary XML database built on a relational mechanism (designed for puns) that offers both relational ( SQL / XML ) and...

  What is PostgreSQL array? In PostgreSQL we can define a column as an array of valid data types. The data type can be built-in, custom or enumerated....

Preamble​​If you are a Linux sysadmin or developer, there comes a time when you need to manage an Oracle database that can work in your environment.In this...

Preamble​​Starting with Microsoft SQL Server 2008, by default, the group of local administrators is no longer added to SQL Server administrators during the...