<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>dbanotes.com</title>
	<atom:link href="http://www.dbanotes.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dbanotes.com</link>
	<description>Data expands knoweldge. Database technology is the tool we use.</description>
	<lastBuildDate>Mon, 04 Feb 2013 13:23:35 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Using SQL Sprocket to generate TSQL Stored Procedures</title>
		<link>http://www.dbanotes.com/database-development/using-sql-sprocket-to-generate-tsql-stored-procedures/</link>
		<comments>http://www.dbanotes.com/database-development/using-sql-sprocket-to-generate-tsql-stored-procedures/#comments</comments>
		<pubDate>Sat, 30 Jun 2012 20:40:20 +0000</pubDate>
		<dc:creator>Michael Ritacco</dc:creator>
				<category><![CDATA[Database Development]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL 2005]]></category>
		<category><![CDATA[SQL 2008]]></category>
		<category><![CDATA[SQL 2012]]></category>

		<guid isPermaLink="false">http://www.dbanotes.com/?p=1142</guid>
		<description><![CDATA[SQL Sprocket is an open source template-based code generating tool designed specifically for SQL Server Database Developers. I have been using this tool for years to enforce standards, reduce errors, and quickly generate any stored procedures required by my development projects. How does SQL Sprocket work? The output generation is based on three types of templates, [...]]]></description>
				<content:encoded><![CDATA[<p>SQL Sprocket is an open source template-based code generating tool designed specifically for SQL Server Database Developers. I have been using this tool for years to enforce standards, reduce errors, and quickly generate any stored procedures required by my development projects.</p>
<p><span id="more-1142"></span></p>
<h3>How does SQL Sprocket work?</h3>
<p>The output generation is based on three types of templates, and the list of tables found in your database:</p>
<ul>
<li>
<div>Table List Statement – User Mode</div>
</li>
<li>
<div>Metadata Templates – Advanced Mode</div>
</li>
<li>
<div>Dictionary Templates – Advanced Mode</div>
</li>
<li>
<div>Output Templates – User Mode</div>
</li>
</ul>
<h3>Table List</h3>
<p>You have full control over the way your database tables are listed in SQL Sprocket. Use the default or update the SQL that populates the list of database tables to your preference.</p>
<h3>Metadata Templates</h3>
<p>Metadata templates give you control over how the data is queried from the SQL Server database and the information provided to the Dictionary Templates. If Microsoft makes any changes to the SQL Server Information_Schema views in a later release just make a quick update to the Metadata Template and you are back to work.</p>
<h3>Dictionary Templates</h3>
<p>Most users will never need to touch the Dictionary or Metadata Templates, but the flexibilty to change how the output is generated using C# or TSQL is available If you need more output types or just want to change the default processing, Dictionary Templates make it possible to tailor the output generation to your needs.</p>
<h3>Output Templates</h3>
<p>Output Template allow you to use the data collected from your database schema along with the &lt;OUTPUT&gt; parameters to generate your database code the way you want it.</p>
<h3>How easy is it to use?</h3>
<p>There is no complex syntax to learn, and you can start generating output based on your SQL Server database in minutes.</p>
<ol>
<li>
<div>Start the tool and connect to your SQL 2012, 2005, or 2008 database.</div>
</li>
<li>
<div>Create the Output templates for your specific development needs or use the TSQL templates provided.</div>
</li>
<li>
<div>Select the tables and templates you want to use to generate code.</div>
</li>
<li>
<div>Click Execute and generate your code.</div>
</li>
<li>
<div>Copy the code to a script or compile it against your database.</div>
</li>
</ol>
<p>SQL Sprocket allows you to define your own generation templates using C# code or TSQL, but did not ship with a TSQL generator out of the box. As a contributor to the SQL Sprocket project, I am pleased to announce the availability of a an example TSQL generator for SQL Sprocket.</p>
<p>I have published both my TSQL generator file and all the output templates I created for the Fulcrum SKMS project. The plan is to provide future templates and updates on the SQL Sprocket Project download page as they are developed.</p>
<p>I hope you will give SQL Sprocket a try and let us know what you think.</p>
<p><strong><div class="woo-sc-box download  rounded "><a title="Mekhano SQL Sprocket" href="http://sqlsprocket.codeplex.com/releases/">Download SQL Sprocket</a></div></strong></p>
<p><strong><div class="woo-sc-box download  rounded "><a id="fileDownload1" title="Fulcrum TSQL Generator and Templates" href="http://sqlsprocket.codeplex.com/downloads/get/419316">Fulcrum TSQL Generator and Templates</a></div></strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.dbanotes.com/database-development/using-sql-sprocket-to-generate-tsql-stored-procedures/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Concepts for Developing Oracle 11g RAC enabled Applications</title>
		<link>http://www.dbanotes.com/database-development/concepts-for-developing-oracle-11g-rac-enabled-applications/</link>
		<comments>http://www.dbanotes.com/database-development/concepts-for-developing-oracle-11g-rac-enabled-applications/#comments</comments>
		<pubDate>Mon, 25 Jun 2012 19:35:02 +0000</pubDate>
		<dc:creator>Contributing Author</dc:creator>
				<category><![CDATA[Database Development]]></category>
		<category><![CDATA[Oracle Database]]></category>
		<category><![CDATA[Oracle11g]]></category>

		<guid isPermaLink="false">http://www.dbanotes.com/?p=1088</guid>
		<description><![CDATA[Introduction Real Application Clusters (RAC) allows multiple computers to run Oracle software simultaneously while accessing a single database, therefore providing a clustered database. In the previous non-RAC oracle database, a single instance accesses a single database. And we know that clustering is the task of assigning a set of objects into groups. In an Oracle [...]]]></description>
				<content:encoded><![CDATA[<p style="text-align: left;" align="center"><strong>Introduction</strong></p>
<p>Real Application Clusters (RAC) allows multiple computers to run Oracle software simultaneously while accessing a single database, therefore providing a clustered database. In the previous non-RAC oracle database, a single instance accesses a single database. And we know that clustering is the task of assigning a set of objects into groups. In an Oracle RAC atmosphere, two or more computers (each with an instance) simultaneously access a single database. This allows an application or user to connect to either computer and have access to a single synchronized set of data. Real Application Clusters offers significant benefits for all system types.</p>
<p><strong>Definition</strong></p>
<p>Real Application Clusters is a network computing solution that allows several nodes (servers) in a clustered system that is present in on shared disk storage. If a single system (node) fails, the service will still be available on the other remaining nodes. Other computers in a network access are not interrupted. All instances can simultaneously execute transactions against the single database. It is an integral part of the Oracle database setup. Oracle Real Application Clusters, or Oracle RAC is a clustering technology that provides the facility to measure performance and recover server availability for Oracle data center environments. However, getting started with Oracle RAC can be difficult and challenging for the Oracle professional who is new to this technology and has worked only with single-instance Oracle databases.</p>
<p><strong>Background</strong></p>
<p>Oracle 11g Clusterware is Oracle&#8217;s implementation of cluster management software, which was introduced in the 10g release of Oracle RAC software. It was originally called <strong>Cluster Ready Services </strong>(<strong>CRS</strong>) and is the complex software that exists under the hood of all Oracle 11g RAC environments. Oracle Clusterware provides several key services essential to an Oracle 11g RAC configuration, including the following:</p>
<ul>
<li> Group Services to manage cluster services within 11g RAC</li>
<li>Node Monitor or the &#8220;heartbeat&#8221; to monitor the status of nodes in 11g RAC cluster</li>
<li>Locking services performed by the LMS database process to manage concurrency activities for 11g RAC cluster</li>
<li>HA Resource management for failover or load-balancing activities in 11g RAC</li>
</ul>
<p>Oracle has had clustering functionality in their product for a long time.  Previously, the clustering technology was more dependent on the Operating System. Oracle chose to incorporate more of the clustering functionality into the Oracle database rather than rely on how the OS does clustering.  Oracle 9i and 10g RAC have more of the key clustering capabilities within Oracle itself.  This means that the clustering is done differently than it was with Oracle Parallel Server(OPS).</p>
<p><strong>Understanding</strong></p>
<p>Oracle RAC is “Shared Everything” clustering.  This allows all nodes in the cluster to have access to the data at the same time.  There is only one set of data that all of the nodes can use at all times. With Real Application Clusters, We can run multiple Oracle instances on systems in a shared disk cluster configuration or on multiple nodes of a Massively Parallel Processor (MPP) configuration. RAC manages traffic between the systems or nodes, authorizing the instances to function as a single database. The failure of a single instance will not cause widespread delays while the system recovers.</p>
<p>Oracle RAC has multiple database instances in comparison to a single instance Oracle database, with each cluster instance in the environment functioning separately, yet in unison with the entire cluster. At the central point of performance, bottlenecks may arise in an RAC database because all of the cluster instances must share access to the RAC database. As such, tuning the pathways to the RAC database is important to ensure a high level of performance. RAC uses a parallel processing-based architecture that shares the resources among all of the cluster nodes. Cache Fusion is the mechanism that provides throughput for the RAC database by using an algorithm to send data between cluster nodes without the previous issues caused by block disk pinging in older versions of the Oracle cluster technology, which was called <strong>Oracle Parallel Clusters </strong>(<strong>OPS</strong>).</p>
<p><strong>Architecture of Oracle RAC</strong><strong>:</strong></p>
<p><strong></strong>Oracle RAC creates a highly available architecture. Oracle RAC is a complex mix of system, network, and database technologies.</p>
<p>Below figure shows an overview of Oracle RAC Database Architecture.  The figure has been shared from Oracle documentation.</p>
<p>&nbsp;</p>
<p><a href="http://www.dbanotes.com/wp/wp-content/uploads/2012/06/dbanotes.com-OracleRACArchitecture.png"><img class="size-full wp-image-1129 aligncenter" title="Oracle RAC Architecture" src="http://www.dbanotes.com/wp/wp-content/uploads/2012/06/dbanotes.com-OracleRACArchitecture.png" alt="" width="428" height="500" /></a></p>
<p align="center"><strong>Figure 1:</strong> <strong>Oracle Database with Oracle RAC Architecture</strong><strong>.</strong></p>
<p>Oracle RAC allows multiple nodes to run multiple instances of Oracle while accessing a single physical database.A cluster includes multiple interconnected computers or servers that perform. Oracle RAC uses Oracle Clusterware for the substructure to bind several servers so that they operate as a single system. An Oracle RAC Databases may have more than 100 instances and all access one database. All database instances essentially use the same interconnection. Oracle Clusterware is a convenient management solution that is combined with the Oracle Database. Oracle RAC is a distinctive technology that provides high accessibility and scalability for all application types. Usually, an Oracle RAC environment is positioned in one data hub. However, we can construct Oracle RAC on an extended distance cluster, which is a design that provides tremendously fast retrieval from a site failure and allows for all nodes.</p>
<p><a href="http://www.dbanotes.com/wp/wp-content/uploads/2012/06/Oracle-Shared-Everything-Architecture.png"><img class="size-full wp-image-1130 aligncenter" title="Oracle Shared Everything Architecture" src="http://www.dbanotes.com/wp/wp-content/uploads/2012/06/Oracle-Shared-Everything-Architecture.png" alt="" width="465" height="463" /></a></p>
<p>&nbsp;</p>
<p align="center"><strong>Fig 2:</strong> <strong>Shared Everything Architecture</strong></p>
<p>Real Application Clusters are designed as “Shared Everything” architecture.  This means that both server resources and storage resources are shared, with a single database image.  This is beneficial for scalability and flexibility.  However, the shared nature of all of the resources (particularly storage) makes it more important than ever to institute High Availability architecture, to avoid single points of failure.</p>
<p>Each node in the cluster has a different physical internet protocol address. However, users (or clients) connect to the database via a virtual database service name.  Oracle automatically balances the user load among the multiple nodes in the cluster.  The RAC database instances on the different nodes subscribe to all or some subset of database services.  This allows you to choose whether specific application clients that connect to a particular database service can connect to some or all of the database nodes.</p>
<p>If more nodes are added to the cluster, the CPU and memory resources of the new node are immediately made available to the rest of the cluster.  (Data does not have to be re-partitioned.)  This allows you to add nodes as you need them.</p>
<p><strong>Oracle 11g RAC components </strong></p>
<p>In addition to the many hardware, network, and storage components that drive the foundation of Oracle 11g RAC, we have the complex software called <strong>Clusterware </strong>that lies at the heart of the Oracle RAC architecture. Oracle 11g RAC consists of these physical devices along with the Clusterware and <strong>Automatic Storage Management </strong>(<strong>ASM</strong>) software. ASM provides the mechanism for managing storage within RAC environments and uses both a special type of instance called an ASM instance and special disk volume management in the form of ASM disks and ASM disk groups. Clusterware refers to the Oracle software layer that performs the operational tasks within the Oracle-clustered environment for RAC. In summary, the Clusterware consists of the following components for Oracle 11g RAC:</p>
<ul>
<li>Voting Disk(s)</li>
<li>Oracle Clusterware Registry (OCR)</li>
<li>Background processes that manage clusterwide operations and provide functionality for Oracle 11g RAC Database</li>
</ul>
<p><strong>Voting Disk: </strong>The <strong>Voting Disk </strong>provides cluster quorum administration within an Oracle 11g RAC environment and is configured on shared storage for the Oracle 11g RAC environment.</p>
<p><strong>Oracle Cluster Registry: </strong>The Oracle Cluster Registry provides housekeeping tasks for maintenance of the Oracle 11g RAC Clusterware infrastructure.</p>
<p><strong>Oracle 11g R1 RAC background processes: </strong>Oracle 11g RAC contains many unique background processes that perform clusterwide operational tasks and management. The majority of these background processes are integrated into the Oracle 11g Clusterware, which is special software used by Oracle to manage cluster operations for RAC environments</p>
<p><strong>Conclusion</strong></p>
<p><strong></strong>In the above discussion of Oracle RAC, we discussed how Oracle RAC manages the instances and aspects of the system architecture Oracle RAC. The article gives the conceptual idea about the Oracle RAC Database in 11g. By using a shared everything architecture, Oracle RAC allows the creation of multiple, independent Oracle instances, all sharing a single database.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dbanotes.com/database-development/concepts-for-developing-oracle-11g-rac-enabled-applications/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Generate dynamic columns using a single variable for PIVOT</title>
		<link>http://www.dbanotes.com/database-development/tsql-dynamic-column-variable-pivot/</link>
		<comments>http://www.dbanotes.com/database-development/tsql-dynamic-column-variable-pivot/#comments</comments>
		<pubDate>Mon, 25 Jun 2012 00:29:26 +0000</pubDate>
		<dc:creator>Michael Ritacco</dc:creator>
				<category><![CDATA[Database Development]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL 2005]]></category>
		<category><![CDATA[SQL 2008]]></category>
		<category><![CDATA[SQL 2012]]></category>

		<guid isPermaLink="false">http://www.dbanotes.com/?p=1028</guid>
		<description><![CDATA[I came across this very handy way of dynamically formatting and converting tables rows into columns for a PIVOT statement. No CURSOR or CTE is required, just a single variable. Run the example against a SQL 2012 instance and you will get the idea. DECLARE @cols AS NVARCHAR(MAX) --=============================================================== -- BUILD THE IN STRING LIST - [...]]]></description>
				<content:encoded><![CDATA[<p>I came across this very handy way of dynamically formatting and converting tables rows into columns for a PIVOT statement. No CURSOR or CTE is required, just a single variable.</p>
<p>Run the example against a SQL 2012 instance and you will get the idea.</p>
<p><span id="more-1028"></span></p>
<pre class="brush:sql">DECLARE @cols AS NVARCHAR(MAX)
--===============================================================
-- BUILD THE IN STRING LIST - NEAT TRICK
--===============================================================
BEGIN
	SELECT @cols =	ISNULL(@cols + ', [', '[') 
			+ CAST([subsystem] as NVARCHAR(100))+ ']'
	  FROM [msdb].[dbo].[syssubsystems]
END

SELECT @cols</pre>
<p class="brush:sql">This works in SQL Server 2000, 2005, 2008, 2012.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dbanotes.com/database-development/tsql-dynamic-column-variable-pivot/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Master Advanced PL/SQL concepts with “Oracle Advanced PL/SQL Developer Professional Guide”</title>
		<link>http://www.dbanotes.com/announcements-news/master-advanced-plsql-concepts-with-oracle-advanced-plsql-developer-professional-guide/</link>
		<comments>http://www.dbanotes.com/announcements-news/master-advanced-plsql-concepts-with-oracle-advanced-plsql-developer-professional-guide/#comments</comments>
		<pubDate>Tue, 03 Apr 2012 01:15:36 +0000</pubDate>
		<dc:creator>Michael Ritacco</dc:creator>
				<category><![CDATA[Announcements & News]]></category>
		<category><![CDATA[Database Development]]></category>

		<guid isPermaLink="false">http://www.dbanotes.com/?p=938</guid>
		<description><![CDATA[The Oracle Advanced PL/SQL Developer Professional Guide helps you to master the advanced PL/SQL concepts in Oracle 11g. The book aims to be a sure selection for the Associate level Oracle professionals aspiring for Professional level. The topics covered and demonstrated are in line with the Oracle University prescription for Oracle Professional certification, which justify the [...]]]></description>
				<content:encoded><![CDATA[<p><img class="alignleft" style="border-style: initial; border-color: initial; border-width: 0px;" src="http://www.dbanotes.com/wp/wp-content/uploads/2012/04/7225EN_mockupcover_normal-243x300.jpg" alt="" width="155" height="192" />The <strong>Oracle Advanced PL/SQL Developer Professional Guide</strong> helps you to master the advanced PL/SQL concepts in Oracle 11g.</p>
<p>The book aims to be a sure selection for the Associate level Oracle professionals aspiring for Professional level. The topics covered and demonstrated are in line with the Oracle University prescription for Oracle Professional certification, which justify the version updates to be advanced and not complex. The book is under publication from Packt publishers and all set for its release in May, 2012.</p>
<p>The OCP 1Z0-146 certification is the second milestone for the Associate level Oracle professionals. The journey from Associate to Professional level enhances your reliability and credibility with the Oracle technology, catalyzes your employability, and job effectiveness.</p>
<p>Apart from focusing the certification preparation, the book contains ample demonstrations and best programming practices, which can be employed in day-to-day assignments.</p>
<p>The book aims to cover the advanced features of PL/SQL, which are required to design and optimize the PL/SQL code. The recapitulation of PL/SQL programming and advanced features like collections, external procedures, server side result caching, implementing VPD to enforce row level security, handling large objects and SecureFiles build up a concrete platform for a PL/SQL professional. Apart from the programming, the book makes instrumental recommendations on the usage of development tool SQL Developer, employing best practices in database environments and safeguarding the vulnerable areas in PL/SQL code to avoid code injection.</p>
<p>The book gives a deeper insight to transform the readers from mid-level programmers to professional database designers. The advanced concepts covered through this book would surely agitate the readers to dig upon and explore more on the topics.</p>
<p>The book is on pre sales on Packt’s website, Amazon and all leading technical book distributors. Book details are as below:</p>
<p>ISBN(10): 1849687226<br />
ISBN(13): 978-1-84968-722-5</p>
<p>Place your order from the below links</p>
<p><a title="Buy from Packt Publishing" href="http://www.packtpub.com/oracle-advanced-pl-sql-developer-professional-guide/book">Buy from Packt Publishing</a></p>
<p><a title="Buy from Amazon" href="http://www.amazon.com/Oracle-Advanced-Developer-Professional-Guide/dp/1849687226">Buy from Amazon</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.dbanotes.com/announcements-news/master-advanced-plsql-concepts-with-oracle-advanced-plsql-developer-professional-guide/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>What is a Database?</title>
		<link>http://www.dbanotes.com/database-administration/what-is-a-database/</link>
		<comments>http://www.dbanotes.com/database-administration/what-is-a-database/#comments</comments>
		<pubDate>Sun, 01 Jan 2012 20:49:13 +0000</pubDate>
		<dc:creator>Michael Ritacco</dc:creator>
				<category><![CDATA[Database Administration]]></category>
		<category><![CDATA[Database Development]]></category>
		<category><![CDATA[Oracle Database]]></category>
		<category><![CDATA[SQL Server]]></category>

		<guid isPermaLink="false">http://dbanotes.com/?p=159</guid>
		<description><![CDATA[For the technical purpose of database developers and administrators, a database is simply a collection of operating system files. Database files are normally stored in a proprietary binary format that can only be mounted by an instance of the relational database software that created them. The purpose of the database instance is to manage and deliver [...]]]></description>
				<content:encoded><![CDATA[<p>For the technical purpose of database developers and administrators, a database is simply a collection of operating system files.</p>
<p>Database files are normally stored in a proprietary binary format that can only be mounted by an instance of the relational database software that created them.</p>
<p>The purpose of the database instance is to manage and deliver the data held within the database files for the users.</p>
<p>Modern Relational Database Management Systems (RDBMS) provide a declarative natural language abstraction layer called SQL to query the data held within the database, and provides <strong>ACID</strong> (<em><a title="Atomicity (database systems)" href="http://en.wikipedia.org/wiki/Atomicity_(database_systems)">atomicity</a>, <a title="Consistency (database systems)" href="http://en.wikipedia.org/wiki/Consistency_(database_systems)">consistency</a>, <a title="Isolation (database systems)" href="http://en.wikipedia.org/wiki/Isolation_(database_systems)">isolation</a>, <a title="Durability (database systems)" href="http://en.wikipedia.org/wiki/Durability_(database_systems)">durability</a></em>) based transactions as a key feature and benefit over other alternatives for data storage.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dbanotes.com/database-administration/what-is-a-database/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Looking forward to SQL Server 2012</title>
		<link>http://www.dbanotes.com/sqlserver-database/looking-forward-to-sql-server-2012/</link>
		<comments>http://www.dbanotes.com/sqlserver-database/looking-forward-to-sql-server-2012/#comments</comments>
		<pubDate>Sun, 01 Jan 2012 20:15:44 +0000</pubDate>
		<dc:creator>Michael Ritacco</dc:creator>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL 2012]]></category>

		<guid isPermaLink="false">http://www.dbanotes.com/?p=880</guid>
		<description><![CDATA[I finally got around to installing SQL Server 2012 RC 0 on VMware Fusion 4 yesterday. Like a kid on Christmas, I started looking for the enhancements that do not get much marketing attention, but will improve my development workflow or put an end to some administration pains. This is what I found so far: [...]]]></description>
				<content:encoded><![CDATA[<p>I finally got around to installing SQL Server 2012 RC 0 on VMware Fusion 4 yesterday. Like a kid on Christmas, I started looking for the enhancements that do not get much marketing attention, but will improve my development workflow or put an end to some administration pains.</p>
<p>This is what I found so far:</p>
<ul>
<li>LocalDB</li>
<li>Sequences</li>
<li>SQL users without Instance logins</li>
<li>File Tables</li>
<li>THROW statement</li>
<li>Support for up to 15,000 partitions</li>
<li>Columnstore indexes</li>
<li>User-defined server roles</li>
<li>Default schemas for a Windows NT Group</li>
<li>ad-hoc query paging for SELECT statements</li>
<li>Support for importing and exporting Spatial data types natively using the SSMS Import/Export utility. For those of you wondering, this is a SSMS client enhancement and in my testing export/import of spatial tables worked between two SQL 2008 R2 databases where it would error on any table containing a spatial data type using the SSMS 2008 R2 client. Thank you SQL Dev Team.</li>
</ul>
<h3>New Functions:</h3>
<div>
<p>Conversion functions</p>
<ul>
<li><a href="http://msdn.microsoft.com/en-us/library/hh213316(v=SQL.110).aspx">PARSE (Transact-SQL)</a></li>
<li><a href="http://msdn.microsoft.com/en-us/library/hh230993(v=SQL.110).aspx">TRY_CONVERT (Transact-SQL)</a></li>
<li><a href="http://msdn.microsoft.com/en-us/library/hh213126(v=SQL.110).aspx">TRY_PARSE (Transact-SQL)</a></li>
</ul>
<p>Date and time functions</p>
<ul>
<li><a href="http://msdn.microsoft.com/en-us/library/hh213228(v=SQL.110).aspx">DATEFROMPARTS (Transact-SQL)</a></li>
<li><a href="http://msdn.microsoft.com/en-us/library/hh213312(v=SQL.110).aspx">DATETIME2FROMPARTS (Transact-SQL)</a></li>
<li><a href="http://msdn.microsoft.com/en-us/library/hh213233(v=SQL.110).aspx">DATETIMEFROMPARTS (Transact-SQL)</a></li>
<li><a href="http://msdn.microsoft.com/en-us/library/hh231077(v=SQL.110).aspx">DATETIMEOFFSETFROMPARTS (Transact-SQL)</a></li>
<li><a href="http://msdn.microsoft.com/en-us/library/hh213020(v=SQL.110).aspx">EOMONTH (Transact-SQL)</a></li>
<li><a href="http://msdn.microsoft.com/en-us/library/hh213396(v=SQL.110).aspx">SMALLDATETIMEFROMPARTS (Transact-SQL)</a></li>
<li><a href="http://msdn.microsoft.com/en-us/library/hh213398(v=SQL.110).aspx">TIMEFROMPARTS (Transact-SQL)</a></li>
</ul>
<p>Logical functions</p>
<ul>
<li><a href="http://msdn.microsoft.com/en-us/library/hh213019(v=SQL.110).aspx">CHOOSE (Transact-SQL)</a></li>
<li><a href="http://msdn.microsoft.com/en-us/library/hh213574(v=SQL.110).aspx">IIF (Transact-SQL)</a></li>
</ul>
<p>String functions</p>
<ul>
<li><a href="http://msdn.microsoft.com/en-us/library/hh231515(v=SQL.110).aspx">CONCAT (Transact-SQL)</a></li>
<li><a href="http://msdn.microsoft.com/en-us/library/hh213505(v=SQL.110).aspx">FORMAT (Transact-SQL)</a></li>
</ul>
</div>
<div>Analytic functions</div>
<div>
<table>
<tbody>
<tr>
<td><a href="http://msdn.microsoft.com/en-us/library/hh231078(v=SQL.110).aspx">CUME_DIST (Transact-SQL)</a></td>
<td><a href="http://msdn.microsoft.com/en-us/library/hh231517(v=SQL.110).aspx">LAST_VALUE (Transact-SQL)</a></td>
<td><a href="http://msdn.microsoft.com/en-us/library/hh231327(v=SQL.110).aspx">PERCENTILE_DISC (Transact-SQL)</a></td>
</tr>
<tr>
<td><a href="http://msdn.microsoft.com/en-us/library/hh213018(v=SQL.110).aspx">FIRST_VALUE (Transact-SQL)</a></td>
<td><a href="http://msdn.microsoft.com/en-us/library/hh213125(v=SQL.110).aspx">LEAD (Transact-SQL)</a></td>
<td><a href="http://msdn.microsoft.com/en-us/library/hh213573(v=SQL.110).aspx">PERCENT_RANK (Transact-SQL)</a></td>
</tr>
<tr>
<td><a href="http://msdn.microsoft.com/en-us/library/hh231256(v=SQL.110).aspx">LAG (Transact-SQL)</a></td>
<td><a href="http://msdn.microsoft.com/en-us/library/hh231473(v=SQL.110).aspx">PERCENTILE_CONT (Transact-SQL)</a></td>
<td></td>
</tr>
</tbody>
</table>
</div>
<div></div>
<h3>Still wishing for:</h3>
<div>
<ul>
<li>ALTER TYPE &#8211; Am I the only one that uses TVPs? Changing the database schema when using TVPs is a dependency nightmare and a mess to deploy the change. VS Ultimate helps, but I will always have reservations with making a change to objects, e.g., all the stored procedures dependent on the TVP, that are not actually having a code change. Please SQL Dev Team, consider prioritizing a usability enhancement for TVPs in the first service pack or R2.</li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.dbanotes.com/sqlserver-database/looking-forward-to-sql-server-2012/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Introduction to Oracle Exadata V2</title>
		<link>http://www.dbanotes.com/general/introduction-to-oracle-exadata/</link>
		<comments>http://www.dbanotes.com/general/introduction-to-oracle-exadata/#comments</comments>
		<pubDate>Sat, 01 Oct 2011 02:11:08 +0000</pubDate>
		<dc:creator>Michael Ritacco</dc:creator>
				<category><![CDATA[Database Administration]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Oracle Database]]></category>
		<category><![CDATA[Exadata]]></category>
		<category><![CDATA[Oracle11g]]></category>

		<guid isPermaLink="false">http://www.dbanotes.com/?p=862</guid>
		<description><![CDATA[This post came out of the difficulty to find the information needed to prepare myself for a week long Exadata proof of concept I have scheduled next month at the Oracle Technology Center  in Menlo Park. The topics listed below should confirm your suspicion that there is significant learning and study required to understand Exadata. [...]]]></description>
				<content:encoded><![CDATA[<p>This post came out of the difficulty to find the information needed to prepare myself for a week long Exadata proof of concept I have scheduled next month at the Oracle Technology Center  in Menlo Park.</p>
<p>The topics listed below should confirm your suspicion that there is significant learning and study required to understand Exadata. Outside of the Oracle Database software (which is the same) there is a lot more complexity to operate an Exadata Machine over a tradtional database server running on Linux, UNIX, Windows. Now I know why Oracle had to change the Exadata marketing from an &#8220;appliance&#8221; to a &#8220;machine&#8221;.</p>
<p>I plan to update these notes once the proof of concept is complete and I fully understand all the nuances of Exadata. Until then, consider this a list of topics and source of suggested resources for further study.</p>
<h3>Exadata Infrastructure Components</h3>
<ul>
<li>Database Servers</li>
<li>Storage Servers</li>
<li>InfiniBand</li>
<li>Flash Cache</li>
<li>CELLBOOT USB Flash Drive</li>
</ul>
<h3>Exadata Software Components</h3>
<ul>
<li>Oracle Automatic Storage Management (ASM)</li>
<li>Oracle Real Application Clusters (RAC). Not required but sales will say it is.</li>
<li>Oracle Database</li>
<li>Linux Logical Volume Manager (LVM)</li>
</ul>
<h3>Connectivity</h3>
<ul>
<li>Database Servers connect to Storage Servers using the Intelligent Database protocol (iDB) implementing the “function shipping” architecture.</li>
<li>iDB use the Reliable Datagram Sockets (RDS) protocol. RDS is designed for low latency and low overhead using less significantly less CPU when compared to UDP and TCP.</li>
<li>iDB is based on libskgxp.</li>
</ul>
<h3>Exadata Database Servers</h3>
<ul>
<li>No storage devices are presented to the OS on the Exadata database servers.</li>
</ul>
<h3>Exadata Storage Servers</h3>
<ul>
<li>Storage Indexes contain min and max values for up to eight columns.</li>
<li>Storage Indexes are 1MB (default) units. Identify locations where the data is not “Reverse Index”. Best for sorted data.</li>
</ul>
<h3>Exadata Smart Scan (Offloading)</h3>
<ul>
<li>Column Projection</li>
<li>Predicate Filtering</li>
<li>Storage Indexes</li>
<li>Bloom Filters</li>
<li>SQL Functions (most single row functions can be offloaded)</li>
<li>Compression and Decompression</li>
<li>Encryption/Decryption</li>
</ul>
<p>Smart Scans not available on:</p>
<ul>
<li>Clustered tables</li>
<li>Index Organized Tabes (IOTs)</li>
<li>When ROWDEPENDENCIES is enabled</li>
</ul>
<h3>Compression Types</h3>
<p><strong>Basic</strong></p>
<ul>
<li>Compression unit is a single Oracle block. 0% PCTFREE</li>
</ul>
<p><strong>OLTP (Advanced Compression)</strong></p>
<ul>
<li>Compression same as basic but uses symbol table to replace repeating values. 10 % PCTFREE for updates</li>
</ul>
<p><strong>Hybrid Columnar Compression (Exadata Storage Only)</strong></p>
<ul>
<li>QUERY LOW uses LZO compression (4x)</li>
<li>QUERY HIGH uses ZLIB compression (6x)</li>
<li>ARCHIVE LOW uses ZLIP compression (7x)</li>
<li>ARCHIVE HIGH uses bzip2 compression (12x)</li>
</ul>
<p>Compression should not be used on tables or partitions where data is updated due to contention.</p>
<h3>Exadata Backup and Recovery</h3>
<ul>
<li>RMAN incremental backups benefit from the storage servers filtering out unchanged blocks.</li>
</ul>
<h3>Recommended Reading:</h3>
<ul>
<li><a href="http://www.amazon.com/gp/product/1430233923/ref=as_li_tf_tl?ie=UTF8&amp;tag=oraclenotescombo&amp;linkCode=as2&amp;camp=217145&amp;creative=399373&amp;creativeASIN=1430233923">Expert Oracle Exadata</a><img style="border: none !important; margin: 0px !important;" src="http://www.assoc-amazon.com/e/ir?t=oraclenotescombo&amp;l=as2&amp;o=1&amp;a=1430233923&amp;camp=217145&amp;creative=399373" alt="" width="1" height="1" border="0" /></li>
<li><a href="http://www.amazon.com/gp/product/0071752595/ref=as_li_tf_tl?ie=UTF8&amp;tag=oraclenotescombo&amp;linkCode=as2&amp;camp=217145&amp;creative=399381&amp;creativeASIN=0071752595">Achieving Extreme Performance with Oracle Exadata (Osborne ORACLE Press Series)</a><img style="border: none !important; margin: 0px !important;" src="http://www.assoc-amazon.com/e/ir?t=oraclenotescombo&amp;l=as2&amp;o=1&amp;a=0071752595&amp;camp=217145&amp;creative=399381" alt="" width="1" height="1" border="0" /></li>
<li><a title="Technical Overview of Oracle Exadata" href="http://http://www.oracle.com/technetwork/database/exadata/exadata-technical-whitepaper-134575.pdf">A Technical Overview of the Oracle Exadata Database Machine and Exadata Storage Server </a></li>
<li><a title="Oracle Exadata Price List" href="http://www.oracle.com/us/corporate/pricing/exadata-pricelist-070598.pdf">Oracle Exadata Price List</a></li>
</ul>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dbanotes.com/general/introduction-to-oracle-exadata/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Understanding Oracle 11g Constraints</title>
		<link>http://www.dbanotes.com/database-development/understanding-oracle-11g-constraints/</link>
		<comments>http://www.dbanotes.com/database-development/understanding-oracle-11g-constraints/#comments</comments>
		<pubDate>Mon, 26 Sep 2011 02:49:42 +0000</pubDate>
		<dc:creator>Contributing Author</dc:creator>
				<category><![CDATA[Database Development]]></category>
		<category><![CDATA[Oracle Database]]></category>
		<category><![CDATA[Oracle11g]]></category>

		<guid isPermaLink="false">http://www.dbanotes.com/?p=791</guid>
		<description><![CDATA[Introduction to Constraints Oracle constraints are defined as the rules to preserve the data integrity in the application. These rules are imposed on a column of a database table, so as to define the basic behavioral layer of a column of the table and check the sanctity of the data flowing into it. The data [...]]]></description>
				<content:encoded><![CDATA[<h3>Introduction to Constraints</h3>
<p>Oracle constraints are defined as the rules to preserve the data integrity in the application. These rules are imposed on a column of a database table, so as to define the basic behavioral layer of a column of the table and check the sanctity of the data flowing into it.</p>
<p>The data which violates the rule, fails to pass the constraint layer and oracle raises a predefined exception. The integrity layer can be further expanded programmatically through triggers and validation subprograms as per the application requirements and standards.</p>
<p>Constraints establish an underlying business nature of data like its uniqueness, its references, NULL behavior or domain oriented limits. The key milestones achieved by the usage of constraints are:</p>
<ul>
<li>Validate NULL property of the data</li>
<li>Validate uniqueness of the data</li>
<li>Validate referential integrity of the data</li>
</ul>
<div>
<h3>Constraint: Common Usage Guidelines</h3>
<p>Before I dig into complete understanding, I shall list the common usage guidelines of constraints.</p>
<ul>
<li>Constraints can be imposed on a single column or group of columns.</li>
<li>Constraints can be defined at column level or table level (except NOT NULL). ‘Column level’</li>
<li>Constraint definition means that the constraint would be associated directly and adjacently to the column. ‘Table level’ constraint definition starts once all the columns are already declared.</li>
<li>Constraints are not only effective while data creation, but also during data modification and deletion.</li>
<li>Constraints can be explicitly added on a table column using ALTER TABLE command</li>
<li>Constraints can be disabled if not required, especially during bulk loads; later they can be re-enabled.</li>
</ul>
<div>
<p>The figure below lists the types of constrains available in Oracle. We shall discuss each one of them in detail.</p>
<p><a href="http://www.dbanotes.com/wp/wp-content/uploads/2011/09/oracle11g-constraints.png"><img class="alignnone size-full wp-image-824" title="oracle11g-constraints" src="http://www.dbanotes.com/wp/wp-content/uploads/2011/09/oracle11g-constraints.png" alt="" width="524" height="193" /></a></p>
<h3>NOT NULL Constraint</h3>
<p>The NOT NULL constraint restricts prevents the inclusion of NULL values in a column. If any NULL values are encountered during insertion, Oracle raises exception ‘ORA-01400: cannot insert NULL into [Column description]’. NOT NULL constraint is also active during update operation; violation of the rule results in exception ‘ORA-10407: cannot update [Column description] to NULL’.</p>
<div>
<h4>Syntax</h4>
<p>[COLUMN NAME] [DATA TYPE] [CONSTRAINT (CONSTRAINT NAME)] [NOT NULL] In the syntax, [CONSTRAINT (CONSTRAINT NAME)] are optional.</p>
<p>Examples:</p>
<p>&#8211;A table NN_DEMO is created with NOT NULL Constraint by name.&#8211;</p>
</div>
<pre class="brush: sql; gutter: true">CREATE TABLE NN_DEMO
(A NUMBER CONSTRAINT CONS_NN_DEMO_A NOT NULL);</pre>
<p class="brush: sql; gutter: true">Table created.</p>
<p>&#8211;A table NN_DEMO is created with NOT NULL Constraint without any name.&#8211;</p>
<pre class="brush:sql">CREATE TABLE NN_DEMO (A NUMBER NOT NULL);</pre>
<p class="brush:sql">Table created.</p>
<p>‘Not Null’ constraint can be defined only at the column level. However, there is no specific exception for the syntax violation in this case.</p>
<p>&#8211;A table NN_DEMO is created with NOT NULL at table level. However, there is no specific exception defined for this violation.&#8211;</p>
<pre class="brush:sql">CREATE TABLE NN_DEMO
(A NUMBER,
NAME VARCHAR2(100),
CONSTRAINT CONS_NN_DEMO_A NOT NULL(A))
/</pre>
<p class="brush:sql">CONSTRAINT CONS_NN_DEMO_A NOT NULL(A)) ERROR at line 4: ORA-00904: : invalid identifier</p>
<h3>UNIQUE Constraint</h3>
<p>As the name suggests, the constraint enforces barrier on the uniqueness of the data. It prevents duplication of the column data, but interestingly allows NULLs. It allows multiple NULLs during creation as well as modification of the column data.</p>
<h4>Syntax</h4>
<p><strong>Column Level:</strong><br />
COLUMN [data type] [CONSTRAINT &lt;name&gt;] [UNIQUE]. At column level, CONSTRAINT keyword and CONSTRAINT_NAME are optional.</p>
<p><strong>Table Level:</strong><br />
CONSTRAINT [constraint name] UNIQUE (column name).At table level, CONSTRAINT keyword and CONSTRAINT_NAME are mandatory.</p>
<h4>Examples</h4>
<p>&#8212;&#8211;Demonstrate column level definition of unique constraint&#8212;&#8211;</p>
<pre class="brush:sql">CREATE TABLE UNIQUE_DEMO_COL 2 (ID NUMBER, NAME VARCHAR2(100) UNIQUE);</pre>
<p>Table created.</p>
<p>&#8212;&#8211;Demonstrate Insertion of Unique Values in the table&#8212;&#8211;</p>
<pre class="brush:sql">INSERT INTO UNIQUE_DEMO_COL VALUES(1,'Name 1');</pre>
<p>1 row created.</p>
<p>&#8212;&#8211;Demonstrate Violation of Unique constraint&#8212;&#8211;</p>
<pre class="brush:sql">INSERT INTO UNIQUE_DEMO_COL VALUES(2,'Name 1');</pre>
<p>ERROR at line 1:ORA-00001: unique constraint (SCOTT.SYS_C0011341) violated</p>
<p>&#8212;&#8211;Demonstrate Table level definition of unique constraint&#8212;&#8211;</p>
<pre class="brush:sql">CREATE TABLE UNIQUE_DEMO (ID NUMBER, NAME VARCHAR2(100),
CONSTRAINT UN_UNIQUE_DEMO_ID UNIQUE(ID));</pre>
<p>Table created.</p>
<p>&#8212;&#8211;Display constraint metadata. Note the Index created&#8212;&#8211;</p>
<pre class="brush:sql">SELECT constraint_name, constraint_type, index_name from user_constraints
where table_name='UNIQUE_DEMO';</pre>
<p>&#8212;&#8211;Demonstrate association of an existing index with Unique Key&#8212;&#8211;</p>
<pre class="brush:sql">CREATE TABLE UNIQUE_DEMO 2 (ID NUMBER, NAME VARCHAR2(100));</pre>
<p>Table created.</p>
<p>&#8212;&#8211;Creating a Unique Index on ID column&#8212;&#8211;</p>
<pre class="brush:sql">CREATE UNIQUE INDEX IDX_UNIQUE_DEMO ON UNIQUE_DEMO(ID);</pre>
<p>Index created.</p>
<p>&#8212;&#8211;Addition of Unique constraint&#8212;&#8211;</p>
<pre class="brush:sql">ALTER TABLE UNIQUE_DEMO ADD CONSTRAINT UN_UNIQUE_DEMO_ID UNIQUE(ID);</pre>
<p>Table altered.</p>
<p>&#8212;&#8211;Verify the association of Index with the unique constraint&#8212;&#8211;</p>
<pre class="brush:sql">SELECT constraint_name, constraint_type, index_name from user_constraints
where table_name='UNIQUE_DEMO';</pre>
<h3>Primary Key Constraint</h3>
<p>As known by its name, Primary key is the ‘most premier’ column of a table. It strictly allows only unique and definite values in the column. Often it is referred to as the hybrid evolution of NOT NULL and UNIQUE, but with different logical and physical implications.</p>
<p>A column or group of columns of a table can be declared as Primary Key of the table. Composite primary keys can accommodate maximum of 32 columns. The declaration can be either made at Column level, Table level or using ALTER TABLE command.</p>
<p>Unlike other constraints, there can be one and only one Primary Key in a table. It can be either a single column or a composite primary key. Oracle raises the exception ‘ORA-02260: table can have only one primary key’, if one attempts to duplicate the primary key in a table.</p>
<h4>Syntax</h4>
<p><strong>Column level:</strong><br />
COLUMN [data type] [CONSTRAINT &lt;constraint name&gt; PRIMARY KEY] At column level, CONSTRAINT keyword and CONSTRAINT_NAME are optional.</p>
<p><strong>Table level:</strong><br />
CONSTRAINT [constraint name] PRIMARY KEY [column (s)]<br />
At column level, CONSTRAINT keyword and CONSTRAINT_NAME are mandatory. Addition of system generated Primary Key</p>
<pre class="brush:sql">ALTER TABLE [TABLE NAME] ADD PRIMARY KEY [COLUMN NAME]</pre>
<p>Above ALTER TABLE command creates a primary key with a system generated name of format SYS_CXX.</p>
<p>Similar to UNIQUE key, a unique b-tree index is always created whenever a primary key is created, with the same name as that of primary key constraint. Remember, a unique key cannot be promoted as the primary key in a table.</p>
<h4>Examples</h4>
<p>&#8212;&#8211;Demonstrate column level definition of Primary key constraint&#8212;&#8211;</p>
<pre class="brush:sql">CREATE TABLE PK_DEMO_1 2 (ID NUMBER PRIMARY KEY, NAME VARCHAR2(100));</pre>
<p>Table created.</p>
<p>&#8212;&#8211;Verify Primary key metadata from USER_CONSTRAINTS. Note that the GENERATED column denotes whether the constraint name has been SYSTEM generated or USER given&#8212;&#8211;</p>
<pre class="brush:sql">SELECT CONSTRAINT_NAME, INDEX_NAME, GENERATED
FROM USER_CONSTRAINTS
WHERE TABLE_NAME='PK_DEMO_1';</pre>
<p>&#8212;&#8211;Demonstrate Table level definition of Primary key constraint&#8212;&#8211;</p>
<pre class="brush:sql">CREATE TABLE PK_DEMO_2 2 ( ID NUMBER, NAME VARCHAR2(100),
CONSTRAINT PK_ID PRIMARY KEY(ID));</pre>
<p>Table created.</p>
<p>&#8212;&#8211;Verify Primary key metadata in USER_CONSTRAINTS. Note the different value for GENERATED column&#8212;&#8211;</p>
<pre class="brush:sql">SELECT CONSTRAINT_NAME, INDEX_NAME, GENERATED FROM USER_CONSTRAINTS WHERE TABLE_NAME='PK_DEMO_2';</pre>
<p>&#8212;&#8211;Demonstrate manual addition of Primary key using ALTER TABLE command&#8212;-</p>
<pre class="brush:sql">CREATE TABLE PK_DEMO_3 (ID NUMBER, NAME VARCHAR2(100));</pre>
<p>Table created.</p>
<pre class="brush:sql">ALTER TABLE PK_DEMO_3 ADD PRIMARY KEY (ID); Table altered.

SELECT CONSTRAINT_NAME, INDEX_NAME, GENERATED FROM USER_CONSTRAINTS WHERE TABLE_NAME='PK_DEMO_3';</pre>
<p>If an index already exists on a column and primary key is created on the same column, the primary key gets associated with the same index.</p>
<h3>Foreign Key Constraint</h3>
<p>Referential integrity is one of the key data features in a normalized database. Two tables can be connected through a column, where one table acts as Parent table while the other one is the child table.</p>
<p>The key column value set in the child table is always the subset of key column value set in the parent table, thus establishing the Parent Child relationship and obeys the referential integrity of data.</p>
<p>The key column in child table is known as Foreign Key i.e. its data references an ‘external or foreign’ set of values.</p>
<p>Now, Oracle follows certain guidelines to establish this relationship.</p>
<ol>
<li>The key column in the Parent table must be a Primary Key.</li>
<li>Multiple Child key columns can refer single Parent key column.</li>
<li>Though the Parent table key column is a Primary Key (which does not allows NULLs), foreign key can accommodate NULL values.</li>
<li>Oracle prevents the deletion of a Parent record, if its corresponding child exists in the child table.<br />
If the constraint is enforced with ON DELETE CASCADE option, then the child record would also be deleted.<br />
If the constraint is enforced with ON DELETE SET NULL option, then the child record would not be deleted, but their key column value would be set to NULL</li>
<li>Oracle prevents the creation of a Child record, for which value of key column does not exists in the Parent table.</li>
</ol>
<h4>Syntax</h4>
<p><strong>Column Level:</strong><br />
COLUMN [data type] [CONSTRAINT] [constraint name] [REFERENCES] [table name (column name)]</p>
<p>[CONSTRAINT] and [constraint name] are optional keywords during Column level declaration.</p>
<p><strong>Table level:</strong><br />
CONSTRAINT [constraint name] [FOREIGN KEY (foreign key column name) REFERENCES] [referenced table name (referenced column name)]</p>
<h4>Examples</h4>
<p>&#8212;&#8211;Creating a Parent table with a Primary key&#8212;&#8211;</p>
<p>CREATE TABLE FK_PARENT (PID NUMBER PRIMARY KEY);</p>
<p>Table created.</p>
<p>&#8212;&#8211;Verify the Primary Key constraint metadata&#8212;&#8211;</p>
<p>SELECT CONSTRAINT_NAME, INDEX_NAME FROM USER_CONSTRAINTS WHERE TABLE_NAME=&#8217;FK_PARENT&#8217;;</p>
<p>&#8212;&#8211;Querying the FK_PARENT table to check the value sets&#8212;&#8211;</p>
<pre class="brush:sql">SELECT * FROM FK_PARENT;</pre>
<p>&#8212;&#8211;Demonstrate Column level definition of foreign key constraint&#8212;&#8211;</p>
<pre class="brush:sql">CREATE TABLE FK_DEMO_1 (CID NUMBER REFERENCES FK_PARENT(PID));</pre>
<p>Table created.</p>
<p>&#8212;&#8211;Multiple foreign keys can refer the same Parent key&#8212;&#8211;</p>
<pre class="brush:sql">CREATE TABLE FK_DEMO_2 (CID NUMBER REFERENCES FK_PARENT(PID));</pre>
<p>Table created.</p>
<p>&#8212;&#8211;Verify the FK constraint metadata in USER_CONSTRAINTS view&#8212;&#8211;</p>
<pre class="brush:sql">SELECT TABLE_NAME, CONSTRAINT_NAME, R_CONSTRAINT_NAME, DELETE_RULE, GENERATED FROM USER_CONSTRAINTS WHERE TABLE_NAME IN ('FK_DEMO_1','FK_DEMO_2');</pre>
<p>&#8212;&#8211;Demonstrate table level definition of foreign key constraint&#8212;&#8211;</p>
<p>CREATE TABLE FK_DEMO_3 2 (CID NUMBER,NAME VARCHAR2(1000),<br />
CONSTRAINT FK_CID FOREIGN KEY (CID) REFERENCES FK_PARENT(PID));</p>
<p>Table created.</p>
<p>&#8212;&#8211;Demonstrate sample data insertion in the Child Table&#8212;&#8211;</p>
<p>INSERT INTO FK_DEMO_3 VALUES (1,&#8217;Insert 1&#8242;);</p>
<p>1 row created.</p>
<p>&#8212;&#8211;Demonstrate violation of foreign key constraint&#8212;&#8211;</p>
<p>INSERT INTO FK_DEMO_3 VALUES (20,&#8217;Insert 20&#8242;); INSERT INTO FK_DEMO_3 VALUES (20,&#8217;Insert 20&#8242;)</p>
<p>ERROR at line 1:<br />
ORA-02291: integrity constraint (SCOTT.FK_CID) violated &#8211; parent key not found</p>
<p>&#8212;&#8211;Exceptionally, NULL is an accepted value in foreign key&#8212;&#8211;</p>
<p>INSERT INTO FK_DEMO_3 VALUES (null,&#8217;Insert 20&#8242;); 1 row created.</p>
<h3>CHECK Constraint</h3>
<p>Till now, we had discussed the constraints which mentor the nature of data flowing into a table column. Now we would see upon the CHECK constraint which monitors the physical data to enforce domain integrity rule on a column.</p>
<p>The CHECK constraint logically fixes the column value by using expressions. If the incoming value satisfies the condition in the expression, it passes through for insertion; in opposite cases, constraint violation exception is raised.</p>
<p>The CHECK constraint expression must use the columns of the same table. Like other constraints, CHECK constraint specification can either be made inline at the column level or can be given at the table level.</p>
<p><strong>Syntax</strong></p>
<p><strong>Column level:</strong><br />
COLUMN [data type] CONSTRAINT [name] [CHECK (condition)]<br />
[CONSTRAINT] and [constraint name] are optional keywords during Column level declaration.</p>
<p><strong>Table level:</strong><br />
CONSTRAINT [name] CHECK (condition)</p>
<p>Additionally, CHECK constraint specification has below restrictions while its specification.</p>
<ul>
<li>Subqueries expressions cannot be used within CHECK expression</li>
<li>Pseudo columns CURRVAL, NEXTVAL, LEVEL, or ROWNUM are not allowed since their value is dynamic</li>
<li>User defined functions and Deterministic functions like CURRENT_DATE, CURRENT_TIMESTAMP, DBTIMEZONE, LOCALTIMESTAMP,SESSIONTIMEZONE,SYSDATE, SYSTIMESTAMP, UID, USER, and USERENV</li>
<li>Composite data types or collections</li>
</ul>
<h4>Examples</h4>
<p>&#8212;&#8211;Demonstrate Column level definition of Check constraint&#8212;&#8211;</p>
<pre class="brush:sql">CREATE TABLE CK_DEMO_1 (ID NUMBER, NAME VARCHAR2(100), EMPLOYED VARCHAR2(1) CHECK (EMPLOYED IN ('Y','N')) );</pre>
<p>Table created.</p>
<p>&#8212;&#8211;Verify Check constraint metadata in USER_CONSTRAINTS table&#8212;&#8211;</p>
<pre class="brush:sql">SELECT constraint_name, search_condition, generated from user_constraints
where table_name='CK_DEMO_1';</pre>
<p>&#8212;&#8211;Demonstrate the insertion</p>
<pre class="brush:sql">INSERT INTO CK_DEMO_1 VALUES (1, 'JOHN','Y');</pre>
<p>1 row inserted.</p>
<p>&#8212;&#8211;Demonstrate the violation</p>
<pre class="brush:sql">INSERT INTO CK_DEMO_1 VALUES 2 (2, 'KATE','A');</pre>
<p>￼ERROR at line 1:<br />
ORA-02290: check constraint (SCOTT.SYS_C0011477) violated</p>
<p>&#8212;&#8211;Demonstrate table level definition of foreign key constraint&#8212;&#8211;</p>
<pre class="brush:sql">CREATE TABLE CK_DEMO_1 (ID NUMBER, NAME VARCHAR2(100), EMPLOYED VARCHAR2(1),
CONSTRAINT CK_EMPLOYED_YN CHECK (EMPLOYED IN ('Y','N')) );</pre>
<p>Table created.</p>
<p>&#8212;&#8211;Demonstrate the restriction of UDF in Check constraint expressions&#8212;&#8211;</p>
<pre class="brush:sql">CREATE OR REPLACE FUNCTION CHECK_RANGE RETURN NUMBER
IS
BEGIN
RETURN 100;
END;
CREATE TABLE CK_DEMO_FUN 2 (ID NUMBER,
NAME VARCHAR2(100), AGE NUMBER CHECK (AGE &lt; CHECK_RANGE));
)</pre>
<p>ERROR at line 5:<br />
ORA-02438: Column check constraint cannot reference other columns</p>
<h3>Constraints: Common Operations</h3>
<h3>Dropping a Constraint</h3>
<p>A constraint can be dropped from a table using ALTER TABLE command. Syntax for the same is as below</p>
<pre class="brush:sql">ALTER TABLE [TABLE NAME] DROP CONSTRAINT [CONSTRAINT NAME]</pre>
<p>For Example, dropping the CHECK constraint from CK_DEMO_1 would be done as below. SQL&gt; alter table ck_demo_1 drop constraint ck_employed_yn;</p>
<p>Table altered.</p>
<h3>Enabling/Disabling a Constraint</h3>
<p>At times, a constraint can be enabled or disabled. Usually, such activities are carried out during data loading from legacy systems. We shall take up a small scenario to illustrate it.</p>
<p>&#8212;&#8211;Verify the data in CK_DEMO_1&#8212;&#8211;</p>
<pre class="brush:sql">SELECT * FROM CK_DEMO_1;</pre>
<p>&#8212;&#8211;Disable the CHECK constraint in table CK_DEMO_1&#8212;&#8211;</p>
<pre class="brush:sql">ALTER TABLE CK_DEMO_1 DISABLE CONSTRAINT CK_EMPLOYED_YN;</pre>
<p>Table altered.</p>
<p>&#8212;&#8211;Inserting a sample data which violates the CHECK constraint expression. The data is successfully inserted&#8212;&#8211;</p>
<pre class="brush:sql">INSERT INTO CK_DEMO_1 VALUES (3, NEL','A');</pre>
<p>1 row created.</p>
<p>&#8212;&#8211;Verify the above insertion in the table&#8212;&#8211;</p>
<pre class="brush:sql">SELECT * FROM CK_DEMO_1;</pre>
<p>&#8212;&#8211;Re-enabling the CHECK constraint raises exception, since the table has the violating data&#8212;&#8211;</p>
<pre class="brush:sql">ALTER TABLE CK_DEMO_1 ENABLE CONSTRAINT CK_EMPLOYED_YN;</pre>
<p>ORA-02293: cannot validate (SCOTT.CK_EMPLOYED_YN) &#8211; check constraint violated</p>
<p>&#8212;&#8211;Deleting the violating data from the CK_DEMO_1 table&#8212;&#8211;</p>
<pre class="brush:sql">DELETE FROM CK_DEMO_1 WHERE EMPLOYED='A';</pre>
<p>ERROR at line 1: ￼1 row deleted.</p>
<p>&#8212;&#8211;Enabling the constraint successfully&#8212;&#8211;</p>
<pre class="brush:sql">ALTER TABLE CK_DEMO_1 ENABLE CONSTRAINT CK_EMPLOYED_YN; Table altered.</pre>
<h3>Conclusion: Seeing the constraints ahead</h3>
<p>Constraints are the first step to impose the integrity rules on the data. They not only check the sanctity of the data, but also define a high level data behavioral layer.</p>
<p>Later versions of Oracle have also introduced data types (POSITIVEN, SIMPLE_INTEGER) which have NOT NULL behavior exhibited in their primitive definitions. These recent developments have moved NOT NULL to an obsolete category.</p>
<p>Over the years, Primary key has emerged to be an important aspect of table designing exercise and data storage philosophies.</p>
<p>The paper covers the basics of constraints available in database. I hope the readers to try their hands out with more concrete scenarios of constraints.</p>
</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.dbanotes.com/database-development/understanding-oracle-11g-constraints/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Google Malware Warning</title>
		<link>http://www.dbanotes.com/announcements-news/google-malware-warning/</link>
		<comments>http://www.dbanotes.com/announcements-news/google-malware-warning/#comments</comments>
		<pubDate>Sun, 04 Sep 2011 21:50:03 +0000</pubDate>
		<dc:creator>Michael Ritacco</dc:creator>
				<category><![CDATA[Announcements & News]]></category>

		<guid isPermaLink="false">http://www.dbanotes.com/wp/?p=755</guid>
		<description><![CDATA[The dbanotes.com site was a recent victim of a published security vulnerability found in the framework our WordPress theme leverages, and as a result, may have been advertising malware to visitors. While we applied the security patch as quickly as possible, we were unfortunately attacked prior to the security patch being published. However, we take [...]]]></description>
				<content:encoded><![CDATA[<p>The dbanotes.com site was a recent victim of a published security vulnerability found in the framework our WordPress theme leverages, and as a result, may have been advertising malware to visitors. While we applied the security patch as quickly as possible, we were unfortunately attacked prior to the security patch being published.</p>
<p>However, we take security very seriously and have performed the necessary response to protect our visitors.</p>
<p>At this time we have notified Google of our actions, and are waiting for Google to perform another scan to give dbanotes.com a clean bill of health.</p>
<p style="text-align: left;">As of Sunday, Sept. 4, 2011, if you get the following browser malware warning you may safely choose to ignore it.</p>
<p style="text-align: left;"><a href="http://www.dbanotes.com/wp/wp-content/uploads/2011/09/googlewarning.png"><img class="alignnone size-full wp-image-756" title="googlewarning" src="http://www.dbanotes.com/wp/wp-content/uploads/2011/09/googlewarning.png" alt="" width="566" height="271" /></a></p>
<p style="text-align: left;"><strong>What was our response to the Security Exploit </strong>?<br />
We rebuilt the entire dbanotes.com site from scratch. New database, new WordPress installation, new Theme installation, and a clean import of all content from backup.</p>
<p>If you still feel you are at risk of getting malware from visiting dbanotes.com, I encourage you to wait until Google removes the official malware warning.</p>
<p>Thank you for your continued support.</p>
<p>Regards,<br />
dbanotes.com</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dbanotes.com/announcements-news/google-malware-warning/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Oracle 11g Pivot Functions</title>
		<link>http://www.dbanotes.com/database-development/oracle-11g-pivot-functions/</link>
		<comments>http://www.dbanotes.com/database-development/oracle-11g-pivot-functions/#comments</comments>
		<pubDate>Sun, 04 Sep 2011 21:15:51 +0000</pubDate>
		<dc:creator>Michael Ritacco</dc:creator>
				<category><![CDATA[Database Development]]></category>
		<category><![CDATA[Oracle Database]]></category>
		<category><![CDATA[Oracle11g]]></category>

		<guid isPermaLink="false">http://www.dbanotes.com/wp/?p=714</guid>
		<description><![CDATA[Data mining, processing and its presentation are the key activities in a production environment. The views and analytic integrals of the information through multiple spectacles can help in better business forecasting and strategic implementations. This innovative exercise of creating varying views might involve aggregation, data transposing, or cross tabulation reporting. Data Pivoting, one of the [...]]]></description>
				<content:encoded><![CDATA[<p>Data mining, processing and its presentation are the key activities in a production environment. The views and analytic integrals of the information through multiple spectacles can help in better business forecasting and strategic implementations. This innovative exercise of creating varying views might involve aggregation, data transposing, or cross tabulation reporting.</p>
<p>Data Pivoting, one of the ways to implement and achieve above purposes, can evolve multiple views with varying combinations of columns as rows and vice versa.<br />
Oracle supports data pivoting through Pivot aggregate operators, which can be used in SQL statements. Oracle 11g introduced two new keywords PIVOT and UNPIVOT in support of this operation. While the PIVOT operation refers to the conversion of rows into columns, UNPIVOT implies the reverse operation.</p>
<p>Prior to the induction of the Pivot operator, such cross tabular reports used to get generated through workaround SQLs using self joins. While it achieved the purpose in small database, it proved to be nightmare in large enterprise data warehouse database systems. Performance used to be the most cursed area where high volume of data was multi folded on self joins.</p>
<h3>PIVOT</h3>
<p>Pivot operator transposes an aggregated row of a table into a column. The distinct row values become the columns in the output and aggregated column value places itself under the appropriate pivoted column. The syntax of Pivot operator is as below.</p>
<div class="woo-sc-box normal   ">
<p>SELECT [COLUMN(S)]<br />
FROM [TABLE NAME]<br />
PIVOT [XML]<br />
( pivot_clause<br />
pivot_for_clause<br />
pivot_in_clause )<br />
WHERE [CONDITIONS]</div>
<p><em>Syntax explanation</em></p>
<ul>
<li>[XML] – optional clause to convert the pivoted data into XML</li>
<li>PIVOT_CLAUSE uses an aggregate function on one of the column of the table. This is the data which places itself against the pivoted column accordingly.</li>
<li>PIVOT_FOR_CLAUSE and PIVOT_IN_CLAUSE specify a column and its distinct values which are to be pivoted. In a transposed report, the distinct values of the pivoted column appear as the header in the output. Both are mandatory clauses, so distinct values of the column must be in hand.</li>
</ul>
<h3>Examples and illustrations</h3>
<p>A retail firm maintains the track of customer sales in three products (Product_A, Product_B, Product_C) for the months of January, February and March. The sales data is collected for three privileged customers C1, C2 and C3.</p>
<p>The relational table CUST_SALES stores the data for each customer against each product in each month. The table data is as below</p>
<p><strong><a href="http://www.dbanotes.com/wp/wp-content/uploads/2011/09/Oracle-11g-Pivot-functions9.jpg"><img class="alignnone size-full wp-image-747" title="Oracle 11g Pivot functions9" src="http://www.dbanotes.com/wp/wp-content/uploads/2011/09/Oracle-11g-Pivot-functions9.jpg" alt="" width="622" height="237" /></a></strong></p>
<p>Now, we shall pivot the table data to give a new analytic dimension. Refer the below cases.</p>
<h3>Case 1: Customer sales in each month for each product</h3>
<p>PRODUCT_ID column of the CUST_SALES table has been pivoted in the below query. Now observe the beauty and intelligence of Pivot operator; it retains the positions of remaining columns (i.e. CUSTOMER_ID and MONTH) and formats the sales data in accordance with the pivoted column. Also note that the PRODUCT_ID is no more a column but its distinct values i.e. Prod A, Prod B,</p>
<p>Prod C are transposed as the column header in the query output.</p>
<div class="woo-sc-box normal   ">SELECT * FROM CUST_SALES<br />
PIVOT<br />
(<br />
SUM(SALES)<br />
FOR PRODUCT_ID<br />
IN (&#8216;Prod A&#8217;, &#8216;Prod B&#8217;, &#8216;Prod C&#8217;)<br />
)</div>
<p>In the above query, note the aggregated function, FOR clause and IN clause of Pivot operator.</p>
<p><strong><a href="http://www.dbanotes.com/wp/wp-content/uploads/2011/09/Oracle-11g-Pivot-functions8.jpg"><img class="alignnone size-full wp-image-746" title="Oracle 11g Pivot functions8" src="http://www.dbanotes.com/wp/wp-content/uploads/2011/09/Oracle-11g-Pivot-functions8.jpg" alt="" width="663" height="165" /></a></strong></p>
<p>Now, check the Explain Plan of the pivot query.</p>
<p>The plan generated shows the pivot specific optimization of the SQL query in HASH GROUP BY function.</p>
<p><strong><a href="http://www.dbanotes.com/wp/wp-content/uploads/2011/09/Oracle-11g-Pivot-functions7.jpg"><img class="alignnone size-full wp-image-745" title="Oracle 11g Pivot functions7" src="http://www.dbanotes.com/wp/wp-content/uploads/2011/09/Oracle-11g-Pivot-functions7.jpg" alt="" width="662" height="197" /></a></strong></p>
<h3>Case 2: Customer sales for each product in each month</h3>
<p>Now, changing the angle of perception by replacing PRODUCT_ID with the MONTH at the header level. Distinct values of MONTH appear as column in the query output.<br />
<div class="woo-sc-box normal   ">SELECT * FROM CUST_SALES<br />
PIVOT<br />
(<br />
SUM(SALES)<br />
FOR MONTH<br />
IN (&#8216;Jan&#8217; as &#8220;January&#8221;, &#8216;Feb&#8217; as &#8220;February&#8221;, &#8216;Mar&#8217; as &#8220;March&#8221;)<br />
)</div></p>
<p>In the query, note that if the value(s) of the pivoted column had to have a customized title for better readability, the same can be specified using “AS” keyword. In the CUST_SALES table, abbreviated values of the MONTH column have been replaced with their complete names.</p>
<p><strong><a href="http://www.dbanotes.com/wp/wp-content/uploads/2011/09/Oracle-11g-Pivot-functions6.jpg"><img class="alignnone size-full wp-image-744" title="Oracle 11g Pivot functions6" src="http://www.dbanotes.com/wp/wp-content/uploads/2011/09/Oracle-11g-Pivot-functions6.jpg" alt="" width="657" height="143" /></a></strong></p>
<p>Similarly, if MONTH column has to be made as key analysis column, CUSTOMER can be raised to column header. Sales data would automatically find its place in the new matrix.<br />
<div class="woo-sc-box normal   ">SELECT * FROM CUST_SALES<br />
PIVOT<br />
(<br />
SUM(SALES)<br />
FOR CUSTOMER_ID<br />
IN (&#8216;Adam&#8217;, &#8216;Jones&#8217;, &#8216;Kanes&#8217;)<br />
)<br />
ORDER BY DECODE(MONTH,&#8217;Jan&#8217;,1,&#8217;Feb&#8217;,2,&#8217;Mar&#8217;,3)</div></p>
<p><strong><a href="http://www.dbanotes.com/wp/wp-content/uploads/2011/09/Oracle-11g-Pivot-functions5.jpg"><img class="alignnone size-full wp-image-743" title="Oracle 11g Pivot functions5" src="http://www.dbanotes.com/wp/wp-content/uploads/2011/09/Oracle-11g-Pivot-functions5.jpg" alt="" width="657" height="148" /></a></strong></p>
<h3>UNPIVOT</h3>
<p>Unpivot operator functions just at the opposite principle of Pivot. Very rare occasions exist when an element is created along with its anti counterpart. Unpivot brings data in pivoted form back to the normal form. Its syntax and usage is same as that of Pivot.<br />
<em>Syntax</em><br />
<div class="woo-sc-box normal   ">UNPIVOT<br />
( unpivot_clause<br />
unpivot_for_clause<br />
unpivot_in_clause )</div></p>
<p>Here, UNPIVOT_CLAUSE is not an aggregated column, but an arbitrary column name, which appears in the query to accommodate the values of unpivoted columns.<br />
UNPIVOT_FOR_CLAUSE is also an arbitrary column name to hold the unpivoted columns values.<br />
UNPIVOT_IN_CLAUSE defines the distinct values of the columns to be unpivoted.</p>
<h3>Illustration</h3>
<p>CUST_SALES_MONTH is the table which holds the data in binary format, to denote whether a product has been consumed by a customer in a specific month or not. It looks more like a spreadsheet.</p>
<p><strong><a href="http://www.dbanotes.com/wp/wp-content/uploads/2011/09/Oracle-11g-Pivot-functions4.jpg"><img class="alignnone size-full wp-image-742" title="Oracle 11g Pivot functions4" src="http://www.dbanotes.com/wp/wp-content/uploads/2011/09/Oracle-11g-Pivot-functions4.jpg" alt="" width="657" height="334" /></a></strong></p>
<p>Now, Unpivot operator can be used here to break the CUST_SALES_MONTH table into rows to show only CUSTOMER_ID, PRODUCT_ID, MONTH and its corresponding sales. Check the query below:<br />
<div class="woo-sc-box normal   ">select * from cust_sales_month<br />
unpivot<br />
(<br />
month_count<br />
for month<br />
in (&#8220;January&#8221;,&#8221;February&#8221;,&#8221;March&#8221;)<br />
)<br />
order by customer_id, product_id<br />
/</div></p>
<p>Now observe the output.</p>
<p><strong><a href="http://www.dbanotes.com/wp/wp-content/uploads/2011/09/Oracle-11g-Pivot-functions3.jpg"><img class="alignnone size-full wp-image-741" title="Oracle 11g Pivot functions3" src="http://www.dbanotes.com/wp/wp-content/uploads/2011/09/Oracle-11g-Pivot-functions3.jpg" alt="" width="663" height="320" /></a></strong></p>
<p>For each customer and product, the „month‟ column is repetitive to list the corresponding „month_count‟ value. The UNPIVOT_FOR_CLAUSE and UNPIVOT_IN_CLAUSE are responsible to have columns of the table listed as value under MONTH column.</p>
<p>The UNPIVOT_CLAUSE (here, MONTH_COUNT) specifies fetches the corresponding value of the unpivoted column and places at correct position alongside its customer_id, product_id and month. This demonstrates the power intelligence of UNPIVOT operator.</p>
<p>The explain plan for the above query shows the UNPIVOT operation for the conversion of column headers as row values.</p>
<p><strong><a href="http://www.dbanotes.com/wp/wp-content/uploads/2011/09/Oracle-11g-Pivot-functions2.jpg"><img class="alignnone size-full wp-image-740" title="Oracle 11g Pivot functions2" src="http://www.dbanotes.com/wp/wp-content/uploads/2011/09/Oracle-11g-Pivot-functions2.jpg" alt="" width="684" height="369" /></a></strong></p>
<h3 align="LEFT">Applications of Pivoting</h3>
<p align="LEFT">We have already seen the benefits of Pivot operator. On need basis, data can be pivoted in the required format. Still, from developers perspective, I would mention an application derived from the previous ones.</p>
<p align="LEFT"><strong>Conversion of columns to rows and vice versa.</strong></p>
<p align="LEFT">For example, you have a test data of known values, which is required in rows. One way is to combine all the separate SELECT statements using UNION operator as below:<br />
<div class="woo-sc-box normal   ">SELECT S1, „Cricket‟ FROM DUAL<br />
UNION<br />
SELECT S2, „Football‟ FROM DUAL<br />
UNION<br />
SELECT S3, „Badminton‟ FROM DUAL<br />
UNION<br />
SELECT S4, „Tennis‟ FROM DUAL<br />
&#8216;S &#8216;CRICKET&#8217; </div><br />
<div class="woo-sc-box normal   ">&#8211; &#8212;&#8212;&#8212;<br />
S1 Cricket<br />
S2 Football<br />
S3 Badminton<br />
S4 Tennis </div></p>
<p align="LEFT">Unpivot operator eases this overhead in efficient and simple way. Check the query below.<br />
<div class="woo-sc-box normal   ">WITH C AS<br />
(SELECT &#8216;Cricket&#8217; s1, &#8216;Football&#8217; s2, &#8216;Badminton&#8217; s3, &#8216;Tennis&#8217; s4<br />
FROM DUAL)<br />
SELECT *<br />
FROM C<br />
UNPIVOT<br />
( VALUE<br />
FOR STRING IN (S1,S2,S3,S4)<br />
)</div></p>
<p>&nbsp;</p>
<p><a href="http://www.dbanotes.com/wp/wp-content/uploads/2011/09/Oracle-11g-Pivot-functions1.jpg"><img class="alignnone size-full wp-image-739" title="Oracle 11g Pivot functions1" src="http://www.dbanotes.com/wp/wp-content/uploads/2011/09/Oracle-11g-Pivot-functions1.jpg" alt="" width="657" height="113" /></a></p>
<h3>Conclusion</h3>
<p>Pivot and Unpivot have made an impactful entry into the SQL language. They have set aside the cumbersome work around solutions and efficiently transpose the data of a relational table.</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dbanotes.com/database-development/oracle-11g-pivot-functions/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
