Search This Blog

T-SQL Query : How to retrieve only the Nth row from a table?

Method 1

SELECT * FROM t1 a
WHERE  n = (SELECT COUNT(rowid)
             FROM t1 b
            WHERE a.rowid >= b.rowid);

Method 2


SELECT * FROM (
  SELECT ENAME,ROWNUM RN FROM EMP WHERE ROWNUM < 101 )

SQL statement : How to Delete duplicates rows from a table?

Choose one of the following queries to identify or remove duplicate rows from a table leaving only unique records in the table:

Method 1:

Delete all rowids that is BIGGER than the SMALLEST rowid value (for a given key):

SQL> DELETE FROM table_name A WHERE ROWID > (
 2    SELECT min(rowid) FROM table_name B
 3    WHERE A.key_values = B.key_values);

Method 2:


This method is usually faster. However, remember to recreate all indexes, constraints, triggers, etc. on the table when done.

SQL> create table table_name2 as select distinct * from table_name1;
SQL> drop table table_name1;
SQL> rename table_name2 to table_name1;


Method 3:


SQL> delete from my_table t1
SQL> where  exists (select 'x' from my_table t2
SQL>                 where t2.key_value1 = t1.key_value1
SQL>                   and t2.key_value2 = t1.key_value2
SQL>                   and t2.rowid      > t1.rowid);

Oracle FAQ : How can one dump/ examine the exact content of a database column?

Table data can be extracted from the database as octal, decimal or hex values:

SELECT DUMP(col1, 10)
FROM tab1
WHERE cond1 = val1;
DUMP(COL1)
-------------------------------------
Typ=96 Len=4: 65,66,67,32

For this example, type=96 is indicating a CHAR column. The last byte in the column is 32, which is the ASCII code for a space. This tells us that this column is blank-padded.

Oracle FAQ : How to select a random collection of rows from a table?

The following methods can be used to select a random collection of rows from a table:

The SAMPLE Clause

From Oracle 8i, the easiest way to randomly select rows from a table is to use the SAMPLE clause with a SELECT statement. Examples:

SELECT * FROM emp SAMPLE(10);

In the above example, Oracle is instructed to randomly return 10% of the rows in the table.

SELECT * FROM emp SAMPLE(5) BLOCKS;

This example will sample 5% of all formatted database blocks instead of rows.

This clause only works for single table queries on local tables. If you include the SAMPLE clause within a multi-table or remote query, you will get a parse error or "ORA-30561: SAMPLE option not allowed in statement with multiple table references". One way around this is to create an inline view on the driving table of the query with the SAMPLE clause. Example:

SELECT t1.dept, t2.emp
FROM (SELECT * FROM dept SAMPLE(5)) t1,
emp t2
WHERE t1.dep_id = t2.dep_id;

If you examine the execution plan of a "Sample Table Scan", you should see a step like this:

TABLE ACCESS (SAMPLE) OF 'EMP' (TABLE)

ORDER BY dbms_random.value()

This method orders the data by a random column number. Example:

SQL> SELECT * FROM (SELECT ename
2 FROM emp
3 ORDER BY dbms_random.value())
4 WHERE rownum <= 3;
ENAME
----------
WARD
MILLER
TURNER

The ORA_HASH() function

The following example retrieves a subset of the data in the emp table by specifying 3 buckets (0 to 2) and then returning the data from bucket 1:

SELECT * FROM emp WHERE ORA_HASH(empno, 2) = 1;

Oracle FAQ : How does one escape special characters when writing SQL queries?

Escape quotes

Use two quotes for every one displayed. Examples:

SQL> SELECT 'Frank''s Oracle site' AS text FROM DUAL;
TEXT
--------------------
Franks's Oracle site

SQL> SELECT 'A ''quoted'' word.' AS text FROM DUAL;
TEXT
----------------
A 'quoted' word.

SQL> SELECT 'A ''''double quoted'''' word.' AS text FROM DUAL;
TEXT
-------------------------
A ''double quoted'' word.

Escape wildcard characters

The LIKE keyword allows for string searches. The '_' wild card character is used to match exactly one character, while '%' is used to match zero or more occurrences of any characters. These characters can be escaped in SQL. Examples:

SELECT name FROM emp 
WHERE id LIKE '%/_%' ESCAPE '/';
SELECT name FROM emp 
WHERE id LIKE '%\%%' ESCAPE '\';

Escape ampersand (&) characters in SQL*Plus

When using SQL*Plus, the DEFINE setting can be changed to allow &'s (ampersands) to be used in text:

SET DEFINE ~
SELECT 'Lorel & Hardy' FROM dual;

Other methods:

Define an escape character:

SET ESCAPE '\'
SELECT '\&abc' FROM dual;

Don't scan for substitution variables:

SET SCAN OFF
SELECT '&ABC' x FROM dual;

Use the 10g Quoting mechanism:

Syntax
q'[QUOTE_CHAR]Text[QUOTE_CHAR]'
Make sure that the QUOTE_CHAR doesnt exist in the text.
SELECT q'{This is Orafaq's 'quoted' text field}' FROM DUAL;

What are the difference between DDL, DML and DCL commands?

DDL - Data Definition Language: statements used to define the database structure or schema. Some examples:

  • CREATE - to create objects in the database
  • ALTER - alters the structure of the database
  • DROP - delete objects from the database
  • TRUNCATE - remove all records from a table, including all spaces allocated for the records are removed
  • COMMENT - add comments to the data dictionary
  • RENAME - rename an object

DML - Data Manipulation Language: statements used for managing data within schema objects. Some examples:

  • SELECT - retrieve data from the a database
  • INSERT - insert data into a table
  • UPDATE - updates existing data within a table
  • DELETE - deletes all records from a table, the space for the records remain
  • MERGE - UPSERT operation (insert or update)
  • CALL - call a PL/SQL or Java subprogram
  • EXPLAIN PLAN - explain access path to data
  • LOCK TABLE - control concurrency

DCL - Data Control Language. Some examples:

  • GRANT - gives user's access privileges to database
  • REVOKE - withdraw access privileges given with the GRANT command

TCL - Transaction Control: statements used to manage the changes made by DML statements. It allows statements to be grouped together into logical transactions.

  • COMMIT - save work done
  • SAVEPOINT - identify a point in a transaction to which you can later roll back
  • ROLLBACK - restore database to original since the last COMMIT
  • SET TRANSACTION - Change transaction options like isolation level and what rollback segment to use

DML are not auto-commit. i.e. you can roll-back the operations, but DDL are auto-commit

SQL server 2008 : LAMBDA EXPRESSIONS

C# 2.0 provided a shorthand method of creating methods and instantiating delegates all in one construct, known as anonymous delegates. C# 3.0 expanded on this idea with a more compact syntactical construct for creating anonymous methods known as lambda expressions. On its most basic level, a lambda expression is simply an anonymous function or method. In Listing 13-8, I've used lambda expressions in two places as arguments to the Average method. The lambda expressions I used were as follows:
p => (float)p.Element("open")
p => (float)p.Element("close")

In both of the preceding lambda expressions, the anonymous function is both declared and instantiated in one expression. Query methods, like the Average method, can accept anonymous functions as parameters— a very powerful feature. Lambda expressions offer many advantages (apart from terseness of code) that .NET 2.0 anonymous delegates do not provide:

SQL server 2008 :LINQ TO XML NAMESPACES

LINQ to XML provides namespace support through the XNamespace object. To create a namespace, just assign the Uniform Resource Identifier (URI) to an XNamespace variable. To use the namespace, just concatenate it to the element name when querying. LINQ to XML automatically expands the namespace-qualified element name out to its fully qualified name internally, so you don't have to worry about it.

SQL server 2008 : SQLXML XPATH LIMITATIONS

SQLXML supports a subset of XPath queries. Following is a list of limitations imposed on the SQLXML XPath implementation:

• The only axis specifiers supported are child, parent, attribute, and self.
• Only element and attribute node types are supported.
• Only predicates that return a boolean result are supported. Numeric predicates like [1] are not supported.
• Only the three XPath data types are supported: string, number, and boolean.
• SQLXML 4 does not support the root query (specified by a forward slash /), or descendant-or-self queries (specified by double slashes //). Every query must begin at a top-level schema element type.
• SQLXML does not support queries that generate a Cartesian product.
• The mod and union (|) operators, string functions, and numeric functions are not supported.

SQL server 2008 : GML

GML is the OGC standard for representation of geospatial data in XML format. SQL Server provides support for a subset of GML, allowing you to create geometry and geography data type instances from GML (or convert them to GML) using built-in data type methods. Y

SQL server 2008 :DTD, XDR, AND XSD

DTDs provide the most basic standard level of validation available to XML. DTDs provide simple structure and string-based content validation; however, they do not provide data typing functionality. DTDs also use a legacy non-XML format inherited from Standard Generalized Markup Language (SGML). DTDs have the advantage of having been part of the XML recommendation since the beginning, so nearly all XML parsers support them to some degree.

XDR schemas represent Microsoft's first attempt at implementing an early working draft of the W3C XML Schema recommendation. XDR functionality is Microsoft-specific, and you won't find it implemented widely on other platforms. XDR functionality for constraining XML structure and typing content has been superseded by the official W3C XML Schema recommendation, and support for XDR is provided for
backward-compatibility reasons. You normally won't use XDR schemas for new functionality, though you might run into them while supporting legacy applications.

SQL server 2008 : HTTP ENDPOINTS AND AD HOC QUERYING

The BATCHES option is a powerful option, but it should be used with care. Any time you allow ad hoc querying of your database, you should carefully consider the security ramifications. I would advise against allowing ad hoc querying over HTTP SOAP endpoints unless you have a compelling reason. And even then you should perform a very thorough security review to ensure that no unauthorized access is allowed to your database and to make sure that users cannot execute destructive ad hoc T-SQL code on your server.

SQL server 2008 : SECURE YOUR SQL SERVER ENDPOINTS

There is some concern from database administrators about exposing SQL Server directly to web traffic via the HTTP SOAP endpoints. This concern is not unreasonable, since you could potentially open up your server to unwanted traffic and attacks from the Internet. However, HTTP SOAP endpoints provide security that is very tightly integrated with SQL Server's built-in security model. If your SQL Server is secure, your exposure to attacks via endpoints is minimized. If your server is not properly secured, endpoints only exacerbate the problem. Of course, an unsecure SQL Server is probably more likely to be attacked using tried-and-true attacks, like SQL injection or password brute-force/dictionary attacks over the standard SQL Server TCP and user datagram protocol ports than via SOAP endpoints.

On the other hand, the vast majority of SQL Servers that are set up to expose web service methods via HTTP SOAP endpoints tend to be set up for internal use only, behind firewalls and with the additional network security provided by network administrators on a local area network or wide area network. If you set up any SQL Server for exposure over the Internet (endpoints enabled or not), make sure you do a thorough security analysis of your server and network to minimize the potential that your server, network, and data can become compromised. Though they are outside the scope of this book, the same type of precautions should be taken when exposing any computer to the Internet, including web servers and other networked computers.

SQL server 2008 : XSL:CHOOSE

The xsl:choose element is analogous to the SQL searched CASE expression. This element contains one or more xsl:when elements that are analogous to WHEN clauses in SQL searched CASE expressions. A SQL searched CASE expression is one where each WHEN clause is a predicate. Like the SQL searched CASE expression, each xsl:when element takes a test attribute that contains an expression. If the expression for an xsl:when element evaluates to true, the content of that element is used. The xsl:choose element can also contain an xsl:otherwise element which is equivalent to the CASE expression's ELSE clause. If all the xsl:when elements evaluate to false, the content of the xsl:otherwise element is used. XSLT does not require that your expression be a true Boolean expression. Any expression in XSLT can evaluate to an effective Boolean value. Chapter 6 has a discussion of effective Boolean value in XQuery.

SQL server 2008 : DHTML, CSS, AND XHTML

In 1999, the W3C approved the HTML 4.01 specification for web-based publishing (this recommendation is commonly known as HTML4). In 2000, the W3C quickly followed up with the XHTML (Extensible HTML) standard, which redefines HTML as an XML application. During this same time, vendors were just starting to get serious about implementing the 1996 W3C recommendation for CSS functionality in their browser products.

Historically speaking, attributes played a key role in HTML formatting. All the way up to HTML4, there is a heavy reliance on attributes to specify colors, borders, spacing, position, and just about every other formatting option supported by HTML. With the adoption of XHTML, most of these attributes were deprecated in favor of the more powerful and flexible CSS model. In an attempt to follow modern user interface coding standards, I've used CSS and generated properly formed HTML in the examples of this chapter. All HTML results have
been tested for standards conformance in both Internet Explorer 6 and Firefox 2.0.

SQL server 2008 : FULL-TEXT CONTAINS VS. XQUERY CONTAINS

The full-text search CONTAINS predicate is not the same as the XQuery contains predicate. The XQuery contains predicate performs a substring match similar to the T-SQL CHARINDEX function. The matches performed by the XQuery contains predicate are case sensitive.
The T-SQL CONTAINS predicate, on the other hand, includes all of the flexibility of the SQL Server full-text search functionality. This includes the ability to perform thesaurus lookups, word stemming, and proximity searches.

The downside to the T-SQL CONTAINS predicate is that you cannot specify node paths to narrow your search using them. The T-SQL full-text search is an all-or-nothing proposition—if you want to search for a word in your XML data using a full-text search, the word can appear anywhere in the XML content. This is why it makes sense to use the T-SQL CONTAINS predicate in conjunction with the XQuery contains predicate for maximum flexibility and performance.

SQL server 2008 : HTTP SOAP Endpoints

A powerful feature introduced in SQL Server 2005, SQL Server 2008 continues providing support for native HTTP SOAP endpoints, which use the XML-based SOAP protocol. HTTP SOAP endpoints provide an efficient, secure, easy-to-configure option for providing SQL Server–based
web service support. The built-in HTTP SOAP endpoint support makes it much easier to expose SQL Server functionality as web services than was previously possible via the Internet Information Server (IIS)–based web services available in SQL Server 2000.

SQL server 2008 : XQuery and XML DML Support

The new xml data type provides several methods to allow querying and modification of XML data. These new methods, including the query(), value(), exist(), nodes(), and modify() methods, support XQuery querying, XML shredding, and XML DML manipulation of your XML data. The SQL Server 2008 XQuery implementation is a powerful subset of the W3C XML Query Language specification, featuring support for path expressions, FLWOR (for-let-whereorder- by-return) expressions, standard functions and operators, and XML DML statements.

SQL server 2008 :FOR XML

SQL Server includes improvements to the legacy FOR XML clause. One improvement is tighter integration with the new xml data type, including options to generate native xml-typed results. FOR XML results can be assigned to variables of the xml data type, with additional support for nesting FOR XML queries, an improvement on the SQL Server 2000 FOR XML clauses, which were limited only to the top level of a SELECT statement. The FOR XML PATH mode, also carried over from SQL Server 2005, is an improvement over the legacy FOR XML EXPLICIT mode. With builtin support for XPath-style expressions, FOR XML PATH makes generating XML in explicit structures
much easier than was possible in SQL Server 2000.

The FOR XML RAW mode has also been improved with additional features, including the ability to rename the default row element name, the ability to explicitly specify the root node, and the ability to retrieve your data in an element-centric format. The FOR XML AUTO and FOR XML EXPLICIT modes have also been improved with additional options and settings.

While some options have been deprecated, several additional options have been added to the FOR XML clauses since the SQL Server 2000 version, including the ELEMENTS XSINIL option, which generates elements for NULLs in the result set, and XMLSCHEMA, which generates an inline XML Schema Definition (XSD) in your XML result. T

SQL server 2008 : XML Indexes

In the SQL Server XML model, whenever you query or manipulate XML data, the data is first converted to a relational format in a process known as shredding. This process can be time consuming when manipulating large XML documents or when querying large numbers of xml data type instances. SQL Server 2008 supports indexing of xml data type columns. Indexing xml columns helps the SQL optimizer significantly improve query performance on XML data stored in the database. The performance is improved by building an index of your XML data by converting it to a relational format, a process known as preshredding. The XML index preshredding process eliminates the shredding step during a query or XML data manipulation, resulting in much faster and less resource-intensive XML query operations. New DML statements have been added to T-SQL to make XML index management relatively easy.

SQL server 2008 xml Data Type - New feature

Prior to SQL Server 2005, SQL Server provided extremely limited support for storing, managing, and manipulating XML data. SQL Server 2000 implemented its XML capabilities through implementation of the FOR XML clause and kludgy LOB data type operations combined with
specialized system-stored procedures. SQL Server 2005 introduced the xml data type, promoting XML data storage and manipulations to first-class status in SQL Server.

The xml data type remains one of the most important XML-specific features in SQL Server 2008. The xml data type supports the storage of typed XML documents and fragments that have been validated against an XML schema collection and untyped XML data which has not. The
xml data type can be used to declare columns in a table, T-SQL variables, parameters, and as the return type of a function. Data can also be cast to and from the xml data type. In addition, the xml data type brings with it a set of methods useful for querying, shredding, and manipulating XML data.

What’s New in SQL Server 2008 XML

SQL Server 2008 provides several enhancements over SQL Server 2000 in terms of XML support and some enhancements over SQL Server 2005. While much of the backward-compatible XML-specific functionality from SQL Server 2000 is available in SQL Server 2008, most of it has been deprecated in favor of the new features and functionality. This section gives a broad  overview of the major enhancements to XML support, which include the following items:

• New xml data type
• XML schema collections
• XML indexes
• FOR XML enhancements, including XPath support in the FOR XML PATH clause
• XQuery and XML DML support
• SQLCLR xml data type support
• Improvements to legacy XML functionality, including improvements to the sp_xml_preparedocument procedure
• HTTP Simple Object Access Protocol (SOAP) endpoints

Oracle Admin : Creating Initial Control Files

The initial control files of an Oracle Database are created when you issue the CREATE DATABASE statement. The names of the control files are specified by the CONTROL_FILES parameter in the initialization parameter file used during database creation. The filenames specified in CONTROL_FILES should be fully specified and are operating system specific. The following is an example of a CONTROL_FILES initialization parameter:

CONTROL_FILES = (/u01/oracle/prod/control01.ctl,
                /u02/oracle/prod/control02.ctl,
                /u03/oracle/prod/control03.ctl)

If files with the specified names currently exist at the time of database creation, you must specify the CONTROLFILE REUSE clause in the CREATE DATABASE statement, or else an error occurs. Also, if the size of the old control file differs from the SIZE parameter of the new one, you cannot use the REUSE clause.

The size of the control file changes between some releases of Oracle Database, as well as when the number of files specified in the control file changes. Configuration parameters such as MAXLOGFILES, MAXLOGMEMBERS, MAXLOGHISTORY, MAXDATAFILES, and MAXINSTANCES affect control file size.

You can subsequently change the value of the CONTROL_FILES initialization parameter to add more control files or to change the names or locations of existing control files.

Oracle : Application Developers Responsibility

Application developers design and implement database applications. Their responsibilities include the following tasks:

  • Designing and developing the database application

  • Designing the database structure for an application

  • Estimating storage requirements for an application

  • Specifying modifications of the database structure for an application

  • Relaying this information to a database administrator

  • Tuning the application during development

  • Establishing security measures for an application during development

Oracle Admin : Security Officers Responsibility

In some cases, a site assigns one or more security officers to a database. A security officer enrolls users, controls and monitors user access to the database, and maintains system security. As a DBA, you might not be responsible for these duties if your site has a separate security officer.

Oracle Admin : Database administrator's responsibilities

A database administrator's responsibilities can include the following tasks:
  • Installing and upgrading the Oracle Database server and application tools

  • Allocating system storage and planning future storage requirements for the database system

  • Creating primary database storage structures (tablespaces) after application developers have designed an application

  • Creating primary objects (tables, views, indexes) once application developers have designed an application

  • Modifying the database structure, as necessary, from information given by application developers

  • Enrolling users and maintaining system security

  • Ensuring compliance with Oracle license agreements

  • Controlling and monitoring user access to the database

  • Monitoring and optimizing the performance of the database

  • Planning for backup and recovery of database information

  • Maintaining archived data on tape

  • Backing up and restoring the database

  • Contacting Oracle for technical support


Oracle Admin : Types of Oracle Database Users

Following Different types of Oracle database Users

  • Database Administrators
  • Security Officers
  • Network Administrators
  • Application Developers
  • Application Administrators
  • Database Users

SQL server 2005 Question With Answer

Question

run a report weekly on Monday. There is a spreadsheet in which I change the Startdate and enddate only in the WeeklyMSfile.xls and worksheet is Weekly and column are A1 and A2. Suppose I am running report on Monday 07, 2008. I will put startdate as 06/30/2008 and Enddate will be 07/07/2008. After putting the date I run the executable file which is looking data from spreadsheet and I get the result in text format.

I just want to automate the spreadsheet to avoid weekly input data of startdate and enddate. My question is how can I create DTS-package so that when I run the DTS-package, automatically change the startdate and enddate and run the executable file.


Answer

Spreadsheet name is: WeeklyMSfile.xls

Executable file name is : WeeklyMS.exe

1. Import the Excel data into a #temptable

2. Change the columns names with sp_rename

3. Export the #temptable to Excel

SQL server 2005 Question With Answer

 Question :I tried to search if this had been asked before but didn't found anything so I hope It has not been 100 times before me.

Is it possible to check if a database allready exist in the SQL Server 2005? If for example I want to create a database called "Testing" I first want to check if the database exists before I create it.

Answer :
if not exists(select * from sys.databases where name = 'Testing')
    create database testing

SQL Query

Question : If a column as has been declared as a primary key with auto increment(IDENTITY(1,1) and it keeps on incrementing when a record is added what can can I do to reinitialise the seed to start at 1 again after deleting all the records in a table.

Answer  1:

You can use the DBCC function or Truncate the table.

 DBCC CHECKIDENT ( <table name>,RESEED,<new value>)

 Truncate Table <table name>

Answer  2:

Here is a simple sample for the question:

--Drop the foreign key

ALTER TABLE dbo.CategoryTable1Sub

DROP CONSTRAINT FK_CategoryID

GO

truncate table dbo.CategoryTable1

truncate table dbo.CategoryTable1Sub

GO

--Add Foreign key back

ALTER TABLE dbo.CategoryTable1Sub ADD CONSTRAINT

FK_CategoryID FOREIGN KEY

( CatID )REFERENCES dbo.CategoryTable1

( Category_ID )

GO


Answer  3:

f you are not able to TRUNCATE, and the issues of removing the CONSTRAINTS are burdensome, as Ken indicated, you may wish to try using the DBCC RESEED functionality.

 

Something like this:

 

DBCC CHECKIDENT ("YourTable", RESEED, 1);.

 

How many places to the right of the decimal can be stored in a CURRENCY data field?

The CURRENCY data type can store up to four places to the right of the decimal.

What is the highest value that can be stored in a BYTE data field?

The highest value that can be stored in a BYTE field is 255. or from
-128 to 127. Byte is a set of Bits that represent a single character.
Usually there are 8 Bits in a Byte, sometimes more, depending on
how the measurement is being made. Each Char requires one byte of
memory and can have a value from 0 to 255 (or 0 to 11111111 in
binary).

Write SQL query

Question : In the domain table we have status as a numeric value from 01 to 04 and we  have text definition of these values in the design document.
Write SQL query to see the result as a text definitions that is corresponded  to these values. (DB2)

Answer:  select TB1.member_id, TB1.bu_id, TB1.program,  TB2.num,
case TB1.status
when '01' then 'Auto renew'
when '02' then 'Expired'
when '03' then 'Sold'
when '04' then 'Terminated'

else TB_name.status
end
       from DB_name.TB_name1  TB1,
DB_name.TB_name2 TB2
       where
       TB1.program in ('com', 'org')
       and TB1.member_role  = '100'
       order by  TB1.member_id
       fetch first 30 rows only

What is transaction? In terms of Database

A. A transaction is a collection of applications code and database
manipulation code bound into an indivisible unit of execution.
it consists from:

BEGIN-TRANSACTION Name
Code
END TRANSACTION Name

What are the main components of Database management systems?

The database management system software includes components for
storage management, concurrency control, transaction
processing, database manipulation interface, database definition
interface, and database control interface.

What is query optimization?

Query optimization is the part of the query process in which the
database system compares different query strategies and chooses the
one with the least expected cost

What Oracle lock modes do you know?

Oracle has two lock modes: shared or exclusive.
Shared locks are set on database resources so that many transactions
can access the resource.
Exclusive locks are set on resources that ensure one transaction has
exclusive access to the database resource

What is Oracle locking?

Oracle uses locking mechanisms to protect data from being destroyed by
concurrent transactions.

Which of the following statements are Data Manipulation Language commands?

A. INSERT
B. UPDATE
C. GRANT
D. TRUNCATE
E. CREATE

How you will create a column alias? (Oracle 8i)

The AS keyword is optional when specifying a column alias. You must
enclose the column alias in double quotes when the alias
contains a space or lowercase letters. If you specify an alias in
lowercase letters without double quotes, the alias will appear in
uppercase.

Which operator do you use to return all of the rows from one query except rows are returned in a second query?

You use the MINUS operator to return all rows from one query except
where duplicate rows are found in a second query. The UNION operator
returns all rows from both queries minus duplicates. The UNION ALL
operator returns all rows from both queries including duplicates.
The INTERSECT operator returns only those rows that exist in both queries.

How Oracle executes a statement with nested subqueries?

When Oracle executes a statement with nested subqueries,it always executes the innermost query first. This query passes its results to the next query and so on until it reaches the outermost query.
It is the outermost query that returns a result set.