Rdbms Notes
Rdbms Notes
This question has bedeviled many people new to Oracle. There are
several products with the letters "SQL" in the title, and these three,
SQL*Plus, SQL, and PL/SQL, are often used together. Because of this,
it's easy to become confused as to which product is doing the work and
where the work is being done. This section briefly describes each of these
three products.
SQL
SQL stands for Structured Query Language. This has become the lingua
franca of database access languages. It has been adopted by the
International Standards Organization (ISO) and has also been adopted by
the American National Standards Institute (ANSI). When you code
statements such as SELECT, INSERT, UPDATE, and DELETE, SQL is the
language you are using. It is a declarative language and is always
executed on the database server. Often you will find yourself coding SQL
statements in a development tool, such as PowerBuilder or Visual Basic,
but at runtime those statements are sent to the server for execution.
PL/SQL
SQL*Plus
What happens when you run SQL*Plus and type in a SQL statement?
Where does the processing take place? What exactly does SQL*Plus do,
and what does the database do? If you are in a Windows environment
and you have a database server somewhere on the network, the following
things happen:
3. The database server executes the query and transmits the results
back to SQL*Plus.
The important thing is that SQL*Plus does not execute your SQL queries.
SQL*Plus also does not execute your PL/SQL code. SQL*Plus simply
serves as your window into the Oracle database, which is where the real
action takes place. Figure 1.1 illustrates this relationship
SQL*Plus is used for most of the examples in this book because of its
universal availability to developers. It is perhaps still the most widely
used tool to develop, test, and create PL/SQL stored subprograms and
SQL queries.
PL/SQL:
The key strength of PL/SQL is its tight integration with the Oracle
database.
Ans 3:
What Is T-SQL?
In the early 1970s, IBM developed SQL (short for Structured Query
Language) for use in its original relational database product named
System R. SQL has one purpose: to query and manipulate data.
T-SQL (short for Transact SQL) is an extension to SQL that adds extra
programming functionality and control mechanisms. T-SQL is the query
language used by not only Microsoft SQL Server but also other database
products, such as Sybases Adaptive Server Enterprise (ASE).
Now that you know how the SELECT statement is used, lets take a look
at what it contains. A basic SELECT statement consists of two parts and
looks like Part1 is where you specify the columns that contain the data
you need. Part2 is where you specify the table or view containing those
columns. The columns that you select must exist in specified table or
view; otherwise, an error will result.
The simplest form of the SELECT statement tells the Query Editor or
Query Analyzer to give you the data in all the columns in the specified
table or view. For example, if you type
in the Query Editor or Query Analyzer, highlight the code, then press
CTRL-E, youll see all the data stored in the sysobjects table in the result
pane. The asterisk (*) is a wildcard that tells the Query Editor or Query
Analyzer to retrieve the data from all the columns in the table.
In the instructions I just gave, note that I had you highlight the code
prior to executing it. Highlighting a code snippet ensures that only that
code is executed. Otherwise, all the code in the query window will be
executed. Also note that I told you to press CTRL-E. Alternatively, you
can press F5 or click the Execute button on the toolbar to execute the
code. I prefer using CTRL-E, though, because it goes hand-in-hand with
CTRL-D and CTRL-T, which let you put the results in a grid format or
text format, respectively. Sysobjects is a system table that exists in every
SQL Server database and contains entries for each database object
within that database. If you dont specify a database when establishing a
connection to SQL Server, youre automatically connected to the default
database, which is the master database (unless you changed this
default). For the purposes here, Im assuming youre connected to the
master database. Typically, you wouldnt spend much time querying
tables in the master database. However, since all instances of SQL Server
have a master database, it serves as a good place to run the sample
queries.
I get the result set that Figure 1 shows. For space reasons, I included
only three of the returned rows and trimmed the length of the columns. (I
also shortened and trimmed the data in the other sample result sets
shown here.) If you try this query, dont be surprised if you get different
results. The data returned depends on which SQL Server version youre
using and what your tables contain. Having different data doesnt matter
at this point because the focus is on the mechanics of the query itself
and not on the details of the data returned.
If you want the result set to display different names for the columns, you
can use the AS clause in a SELECT statement. For example, if you want
to retrieve the name, type, and crdate columns but want to name them
ObjectName, ObjectType, and Creation- Date, respectively, you can run
the query
In this query, the = operator is being used to see whether each value in
the type column is equal to U. If so, that object is returned in a result set
that will look something like the one in Figure 3. The = operator is one of
several comparison operators you can use in a WHERE clause, as Table
1 shows.
As Figure 4 shows, the returned result set contains only those objects
that meet the criteria.
You shouldnt use the ORDER BY clause in views, derived tables, inline
functions, and subqueries, unless you also use the TOP command.
Otherwise, you might get an error message. (If youd like to know why the
sometimes error occurs, see the Microsoft article at
support.microsoft.com/kb/841845.)
Topic Description
Features of SQL Server Highlights the features of Microsoft SQL Server
2000 2000.
Relational Database Describes the main relational database
Components components of SQL Server 2000, including the
database engine itself and the components
involved in communications between applications
and the database engine.
Database Architecture Describes the logical components defined in SQL
Server databases and how they are physically
implemented in database files.
Relational Database Describes the features of the server engine that
Engine Architecture make it efficient at processing large numbers of
concurrent requests for data from many users.
Administration Describes how the easy-to-use tools provided with
Architecture SQL Server 2000 and the dynamic configuration
capabilities of SQL Server minimize routine
administrative tasks.
Replication Describes the replication components of SQL
Architecture Server 2000 and how they can be used to
distribute data between databases.
Data Warehousing and Describes Data Transformation Services (DTS)
Online Analytical and Microsoft SQL Server 2000 Analysis Services,
Processing and how they help in building and analyzing a
data warehouse or data mart.
Application Describes how SQL Server 2000 supports the
Development various database programming APIs, which allow
Architecture users to build robust database applications.
Implementation Details Provides implementation details, such as the
maximum capacities of Transact-SQL statements,
the ranges of SQL Server configuration options,
memory usage of SQL Server objects, and the
differences among the editions of Microsoft SQL
Server.
Internet Integration.
Data warehousing.
Oracle Instance
Oracle Process
o PMON, SMON, DBWR, LGWR, CKPT
o Server Process
Memory Structure Update!(May7,2002)
o SGA
Shared pool
Library Cache
Data Dictionary cache
Database Buffer cache
Redo buffer cache
o PGA
Data files
Control files
Redo log files
Archived log files
Parameter file
Password file
Oracle Clients
user process
Oracle Net
Hardware requirements
To install SQL Server 2000, you should have the Intel or compatible platforms and the
following hardware:
Hardware Requirements
Processor Pentium 166 MHz or higher
32 MB RAM (minimum for Desktop Engine),
Memory 64 MB RAM (minimum for all other editions),
128 MB RAM or more recommended
270 MB (full installation),
250 MB (typical),
95 MB (minimum),
Hard disk space Desktop Engine: 44 MB
Analysis Services: 50 MB minimum and 130 MB
typical
English Query: 80 MB
To install Oracle 9i under the Intel or compatible platforms, you should have the
following hardware:
Hardware Requirements
Processor Pentium 166 MHz or higher
RAM: 128 MB (256 MB recommended)
Memory Virtual Memory: Initial Size 200 MB, Maximum Size
400 MB
140 MB on the System Drive
Hard disk
plus 4.5 GB for the Oracle Home Drive (FAT)
space
or 2.8 GB for the Oracle Home Drive (NTFS)
To install Oracle 9i Database under the UNIX Systems, such as AIX-Based Systems,
Compaq Tru64 UNIX, HP 9000 Series HP-UX, and Sun Solaris, you should have the
following hardware:
Hardware Requirements
Memory A minimum of 512 MB RAM
A minimum of 2 x RAM or 400 MB, whichever is
Swap Space
greater
Hard disk
4.5 GB
space
Software requirements
SQL Server 2000 comes in six editions: Enterprise, Standard, Personal, Developer,
Desktop Engine, and SQL Server CE (a compatible version for Windows CE) and
requires the following software:
SQL
Operating Enterprise Standard Personal Developer Desktop
Server
System Edition Edition Edition Edition Engine
CE
Windows CE No No No No No Yes
Windows 9x No No Yes No Yes No
Windows NT
4.0
Workstation No No Yes Yes Yes No
with Service
Pack 5
Windows NT
4.0 Server
Yes Yes Yes Yes Yes No
with Service
Pack 5
Windows NT
4.0 Server
Enterprise
Yes Yes Yes Yes Yes No
Edition with
Service
Pack 5
Windows
2000 No No Yes Yes Yes No
Professional
Windows
Yes Yes Yes Yes Yes No
2000 Server
Windows
2000
Yes Yes Yes Yes Yes No
Advanced
Server
Windows
2000 Yes Yes Yes Yes Yes No
DataCenter
Windows XP
No No Yes Yes Yes No
Professional
Oracle 9i Database comes in three editions: Enterprise, Standard and Personal and
requires the following software:
Operating System
Platform Required Patches
Version
Windows-based Windows NT 4.0 Service Pack 5
Windows-based Windows 2000 Service Pack 1
Windows-based Windows XP Not Necessary
Maintenance Level 09 and
AIX-Based AIX 4.3.3 IY24568,
IY25282, IY27614, IY30151
AIX 5L release 5.1 ML01+
(IY22854),
AIX-Based AIX 5.1
IY26778, IY28766, IY28949,
IY29965, IY30150
Compaq Tru64
Tru64 5.1 5.1 patchkit 4
UNIX
Compaq Tru64
Tru64 5.1A 5.1A patchkit 1
UNIX
HP-UX HP-UX version 11.0 Sept. 2001 Quality Pack,
(64-bit) PHCO_23792,
PHCO_24148, PHKL_24268,
PHKL_24729,
PHKL_ 25475, PHKL_25525,
PHNE_24715,
PHSS_23670, PHSS_24301,
PHSS_24303,
PHSS_24627, PHSS_22868
SuSE Linux
Enterprise Server 7
Linux (or SLES-7) with Not Necessary
kernel 2.4.7,
and glibc 2.2.2
Solaris 32-Bit 2.6
Sun Solaris (5.6), 7 (5.7) Not Necessary
or 8 (5.8)
Sun Solaris Solaris 64-Bit 8 (5.8) Update 5
Performance comparison
It is very difficult to make the performance comparison between SQL
Server 2000 and Oracle 9i Database. The performance of your databases
depends rather from the experience of the database developers and
database administrator than from the database's provider. You can use
both of these RDBMS to build stable and efficient system. However, it is
possible to define the typical transactions, which used in inventory
control systems, airline reservation systems and banking systems. After
defining these typical transactions, it is possible to run them under the
different database management systems working on the different
hardware and software platforms.
TPC tests
The Transaction Processing Performance Council (TPC.Org) is
independent organization that specifies the typical transactions
(transactions used in inventory control systems, airline reservation
systems and banking systems) and some general rules these
transactions should satisfy.
The TPC organization made the specification for many tests. There are
TPC-C, TPC-H, TPC-R, TPC-W and some old tests, such as TPC-A, TPC-B
and TPC-D. The most popular test is the TPC-C test (OLTP test).
At the moment the article was wrote, SQL Server 2000 held the top TPC-
C by performance results with Distributed Partitioned Views-based
cluster systems.
See Top Ten TPC-C by Performance Version 5 Results
At the moment the article was wrote, SQL Server 2000 held the top TPC-
C by price/performance results. See Top Ten TPC-C by
Price/Performance Version 5 Results
Note. Because most organizations really do not run very large databases,
so the key points on which SQL Server 2000 won the TPC-C benchmarks
do not really matter to the vast majority of companies.
Price comparison
One of the main Microsoft SQL Server 2000 advantage in comparison
with Oracle 9i Database is that SQL Server is cheaper. Other SQL Server
advantage is that Microsoft includes the Online analytical processing
(OLAP) and Data Mining as standard features in SQL Server 2000
Enterprise Edition. So, you can save up to four times with SQL Server
2000 Enterprise Edition if you use OLAP and Data Mining.
Compare pricing for SQL Server 2000 Standard Edition and Oracle9i Standard Edition:
Compare pricing for SQL Server 2000 Enterprise Edition (which include OLAP and Data
Mining) and Oracle9i Enterprise Edition with OLAP and/or Data Mining:
Oracle9i Oracle9i
SQL Server
Oracle9i Enterprise Enterprise
Number of 2000
Enterprise Edition with Edition With
CPUs Enterprise
Edition OLAP or Data OLAP and Data
Edition
Mining Mining
1 $40,000 $60,000 $80,000 $19,999
2 $80,000 $120,000 $160,000 $39,998
4 $160,000 $240,000 $320,000 $79,996
8 $320,000 $480,000 $640,000 $159,992
16 $640,000 $960,000 $1,280,000 $319,984
32 $1,280,000 $1,920,000 $2,560,000 $639,968
Note. This is not a full price comparison between SQL Server 2000 and
Oracle 9i Database. It is only a brief comparison. You can have any
discounts and the prices can be increased or decreased in the future. See
Microsoft and Oracle to get more information about the price of their
products.
Features comparison
Both SQL Server 2000 and Oracle 9i Database support the ANSI SQL-92
entry level and do not support the ANSI SQL-92 intermediate level. In the
Features comparison section of this article I want to make the brief
comparison of the Transact-SQL with PL/SQL and show some SQL
Server 2000 and Oracle 9i Database limits.
T-SQL vs PL/SQL
The dialect of SQL supported by Microsoft SQL Server 2000 is called Transact-SQL (T-
SQL). The dialect of SQL supported by Oracle 9i Database is called PL/SQL. PL/SQL is
more powerful language than T-SQL. This is the brief comparison of PL/SQL and T-SQL:
Oracle 9i
Feature SQL Server 2000
Database
database name length 128 8
column name length 128 30
index name length 128 30
table name length 128 30
view name length 128 30
stored procedure name length 128 30
max columns per index 16 32
max char() size 8000 2000
max varchar() size 8000 4000
max columns per table 1024 1000
max table row length 8036 255000
max query size 16777216 16777216
recursive subqueries 40 64
constant string size in SELECT 16777207 4000
constant string size in WHERE 8000 4000
Conclusion
It is not true that SQL Server 2000 is better than Oracle 9i or vice versa.
Both products can be used to build stable and efficient system and the
stability and effectiveness of your applications and databases depend
rather from the experience of the database developers and database
administrator than from the database's provider. But SQL Server 2000
has some advantages in comparison with Oracle 9i and vice versa.