Wednesday, June 14, 2017

Cloning Pluggable Database In Oracle 12c

How to Clone an existing pluggable database in Oracle 12c.

Step 1:-

Verify all the databases present in the system.

Select name,pdb from v$services
NAME                                              PDB
--------                                            ----------
SYS$BACKGROUND                  CDB$ROOT
SYS$USERS                                 CDB$ROOT     
TESTPDB                                     PDB.DOMAIN.COM

Let’s follow the below steps to clone the PDB “TESTPDB” to “TESTPDB_CP”.

Step 2:-

Close the pluggable database TESTPDB.

Sql > Alter pluggable database TESTPDB close

Step 3:-

Open the pluggable database TESTPDB in read only mode.

Sql > Alter pluggable database TESTPDB open read only

Step 4:-

Create the new pluggable database TESTPDB_CP from the pluggable database TESTPDB.

Sql > create pluggable database TESTPDB_CP from TESTPDB
          file_name_convert = (‘/TESTPDB’,’/TESTPDB_CP’)


Step 5:-

Open the source pluggable database TESTPDB in read write mode.

Sql > Alter pluggable database TESTPDB open

Step 6:-

Open the new pluggable database TESTPDB_CP in read write mode.

Sql > Alter pluggable database TESTPDB_CP open

Step 7:-

Now we can check the status of all the PDB’s.


Select name,pdb from v$services;

Friday, February 19, 2016

Business Intelligence Architecture

Web Application development In PL/SQL

Web-enabling PL/SQL-based Database Applications
There are a number of ways to Web-enable your existing PL/SQLbased
database applications. Each of them has its own system
requirements and benefits, and is suitable to certain application
categories or deployment environments. You should consider your
application needs and pick the one that is the most suitable to you.
The figure above summarizes the matching of different application
categories and the Web-enabling solutions.
This presentation focuses on three different application categories:
• Oracle Developer applications
• Custom-GUI applications
• Applications without GUI
Additionally, this presentation covers the following Web-enabling
solutions for the above application categories:
• Oracle Developer Web-deployment
• Oracle WebDB
• PL/SQL Web Toolkit
• PL/SQL Server Pages (PSP)
• Java Applets
• CGI

NoSQL Introductory

NoSQL
The data grows day by day due to high usage of Mobile, social, and cloud computing resources. Data management requirements go beyond the effective scope of traditional relational databases.
So companies are looking to capitalize on the advantage of alternatives like NoSQL and Hadoop: NoSQL to build operational applications that drive their business through systems of engagement, and Hadoop to build applications that analyze their data retrospectively and help deliver powerful insights.
MongoDB
It has been Written in: C++.
MongoDB has aimed for a balanced approach suited to a wide variety of applications. While the functionality is close to that of a traditional relational database, MongoDB allows users to capitalize on the benefits of cloud infrastructure with its horizontal scalability and to easily work with the diverse data sets in use today thanks to its flexible data model.
MongoDB is mainly designed for OLTP workloads. It can do complex queries, but it’s not necessarily the best fit for reporting-style workloads. Or if you need complex transactions, it’s not going to be a good choice. However, MongoDB’s simplicity makes it a great place to start.
Cassandra
It has been Written in Java.
There are at least two kinds of database simplicity: development simplicity and operational simplicity. While MongoDB rightly gets credit for an easy out-of-the-box experience, Cassandra earns full marks for being easy to manage at scale.
As for adding capacity to a cluster, “You simply boot up a new machine and tell Cassandra where the other nodes are, and it takes care of the rest.”
This ease of scaling, coupled with exceptional write performance (“All you’re doing is appending to the end of a log file”) and predictable query performance, add up to a high-performance workhorse in Cassandra.
The replication and read and write paths are purposefully simple. You can learn the core internals of Cassandra in a few hours. That can bring a lot of confidence as you deploy new technology because there are less “black box” details that introduce complex failure modes.
This means that the price for admission to effective Cassandra development is in understanding the data model and how it will work with your application.
CQL3 is very similar SQL, but with some limitations that come from the scalability (most notably: no JOINs, no aggregate functions.)
Map/reduce possible with Apache Hadoop
All nodes are similar, as opposed to Hadoop/HBase

HBase
It has been Written in Java.
HBase, like Cassandra a column-oriented key-value store, gets a lot of use in large part because of its common pedigree with Hadoop. HBase provides a record-based storage layer that enables fast, random reads and writes to data, complementing Hadoop by emphasizing high throughput at the expense of low-latency I/O. Changes are efficiently cataloged in memory to achieve maximum access while the data is persisted to HDFS. This design enables a Hadoop-based EDH [enterprise data hub] to serve random reads and writes to users and applications in real time, yet still enjoy the fault- tolerance and durability of HDFS.
HBase’s roots as an open source implementation of Google’s Bigtable translate into the database being highly scalable by design.
Because it can utilize the storage, memory, and CPU resources of any number of servers, as well as has scale-out features like automatic sharding, HBase can scale limitlessly as load and performance demands increase simply by adding server nodes. HBase was designed from the ground up to provide optimal performance when consistency is critical.
But scale isn’t it’s only utility. “Thanks to its tight integration with the rest of the Hadoop ecosystem, data is readily available to users and applications via SQL queries (using Cloudera Impala, Apache Phoenix, or Apache Hive) or even faceted free-text search (using Cloudera Search).” Thus, HBase gives developers a way to leverage existing expertise with SQL while building on a more modern, distributed database.
Limitations of NoSQL
NoSQL alternatives and solutions are still in nascent and pre-production stages and many key features are yet to be implemented.
Customer support is also better in RDBMS systems like SQL and vendors provide a higher level of enterprise support. In contrast, NoSQL system support is provided by small start-up companies.

They offer few facilities for ad-hoc query and analysis. It is much easier to code an SQL query, commonly used BI tools do not provide connectivity to NoSQL.

Thursday, February 18, 2016

Performance Monitoring SQL

It will Show sessions along with operations which is doing full table scan or any sort operation which may consume lots of resources.

SELECT SID, SERIAL#, opname, SOFAR, TOTALWORK, START_TIME,
ROUND(SOFAR/TOTALWORK*100,2) COMPLETE
FROM   V$SESSION_LONGOPS
WHERE SOFAR <> TOTALWORK;

Through the below sql we need to find out the queries which is currently running for more than 60 seconds.
SELECT nvl(ses.username,'ORACLE PROC')||' ('||ses.sid||')' USERNAME,
       SID,  
       MACHINE,
       REPLACE(SQL.SQL_TEXT,CHR(10),'') STMT,
      ltrim(to_char(floor(SES.LAST_CALL_ET/3600), '09')) || ':'
       || ltrim(to_char(floor(mod(SES.LAST_CALL_ET, 3600)/60), '09')) || ':'
       || ltrim(to_char(mod(SES.LAST_CALL_ET, 60), '09'))    RUNT
  FROM V$SESSION SES,  
       V$SQLtext_with_newlines SQL
 where SES.STATUS = 'ACTIVE'
   and SES.USERNAME is not null
   and SES.SQL_ADDRESS    = SQL.ADDRESS
   and SES.SQL_HASH_VALUE = SQL.HASH_VALUE
order by runt desc, 1,sql.piece;

Show sessions holding a TX lock:
    SELECT * FROM v$lock vl, v$session vs, v$sqltext vt
     WHERE vl.TYPE = 'TX'
       AND vl.lmode > 0
       AND vl.sid = vs.sid
       AND vs.SQL_ADDRESS    = vt.ADDRESS
       AND vs.SQL_HASH_VALUE = vt.HASH_VALUE

Show sessions waiting for a TX lock:
    SELECT * FROM v$lock vl, v$session vs, v$sqltext vt
     WHERE vl.TYPE = 'TX'
       AND vl.request > 0
       AND vl.sid = vs.sid
       AND vs.SQL_ADDRESS    = vt.ADDRESS



       AND vs.SQL_HASH_VALUE = vt.HASH_VALUE