Академический Документы
Профессиональный Документы
Культура Документы
___________________________________________________________________________________________________
Copyrights Reserved Page 1 of 27
Introduction
DATABASE
DBMS Vs RDBMS
TYPES OF RDBMS
TOOLS IN SYBASE
FEATURES OF SYBASE
Data Types
Constraints
Indexes
Queries
___________________________________________________________________________________________________
Copyrights Reserved Page 2 of 27
Database
Collection of data
It a structure for storing information.
They are typically organized into tables, having collections of records
You may think of a table as a collection of columns and rows.
For example, a table named Employee might contain the EmpID, Empname,
Empsalary, Emp desigination and other information about that employee.
Each row is called a data record and each column is called a record field.
Relational Database
A relational database is a database that conforms to the relational
model, and refers to a database's data and schema (the database's
structure of how that data is arranged).
DBMS permits only one person to access the database at a given time, on
the other hand RDMS allows many users simultaneous access to the
database.
RDBMS leads DBMS
Security wise
Used in large organizations to store large amount of data.
It has quick retrieval mechanisms.
___________________________________________________________________________________________________
Copyrights Reserved Page 3 of 27
What is SYBASE?
It is database server developed by Sybase Corp. Which was Architect by
To communicate with the sql server and to manipulate objects stored in sql
server, client programs and SP use a variety of Structured Query language
is called T-SQL
T-sql extends sql by adding program flow-control constructs, local variables
and other capability to allow the DBA to build code-based objects in SP and
Trigger.
What are the Versions we have till now ?
The following is a list of the versions of ASE released over the years:
Sybase SQL Server 3.0 – the first publicly released version of the product
released in 1988. Sybase SQL Server 4.0 – released in 1990.
Sybase SQL Server 4.2 – released in 1991.
Sybase SQL Server 4.8 – released in 1992.
Sybase SQL Server 4.9 – also released in 1992, along with version 4.9.1;
version 4.9.2 was released in 1993.
Sybase System X, aka Sybase SQL Server 10.0 – released in 1993.
Sybase SQL Server 11.0 – released in 1995.
Adaptive Server Enterprise 11.5 – released in 1997. --> (The version which
we are using right now)
Adaptive Server Enterprise 11.9 – released in 1998. It does not appear that
version 11.9.0 was ever publicly released; instead 11.9.2 was the released
version, and 11.9.3 was the first 64 bit version made available.
Adaptive Server Enterprise 12.0 – released in 1999.
Adaptive Server Enterprise 12.5 – released in 2001.
Adaptive Server Enterprise 12.5.0.1 – released in 2002, along with version
___________________________________________________________________________________________________
Copyrights Reserved Page 4 of 27
12.5.0.2.
Adaptive Server Enterprise 12.5.0.3 – released in 2003, along with version
12.5.1.
Adaptive Server Enterprise 12.5.2 – released in 2004, along with version
12.5.3.
Adaptive Server Enterprise 12.5.3a – released in 2004/2005.
Adaptive Server Enterprise 12.5.4 – released in 2006.
Adaptive Server Enterprise 15.0 – released in 2005, along with version
12.5.3.
Adaptive Server Enterprise 15.0.1 – released in 2006.
Adaptive Server Enterprise 15.0.2 – due for release in 2007.
Types of RDBMS:
SYBASE.
MS SQL SERVER.
MYSQL.
Microsoft ACCESS.
DB2.
TERADATA
Sybase Vs Oracle
___________________________________________________________________________________________________
Copyrights Reserved Page 5 of 27
An Oracle instance consists of:
Data files which contain the tables and other data objects, control files
which contain configuration information, redo log files for transaction
processing, and archive files for recovery purposes.
Memory Model
Sybase:
The program area, which is where the dataserver executable is stored.
The data cache, stores recently fetched pages from the database device.
The stored procedure cache, which contains optimized sql calls.
Oracle:
The shared pool, which is split between the library cache and data
dictionary cache, optimized queries are stored here.
The redo log buffer, which is where transactions are stored before they are
written to the redo logs.
Transaction Processing
Sybase:
Transactions are written to the data cache, where they advance to the
transaction log, and database device. When a rollback occurs, pages are
discarded from the datacache. The transaction logs are used to restore data
in event of a hardware failure. A checkpoint operation flushes all updated
(committed) memory pages to their respective tables.
Transaction logging is required for all databases; only image (blob) fields
may be exempt.
During an update transaction, the data page(s) containing the row(s) are
locked. This will cause contention if the transaction is not efficiently written.
Record locking can be turned on in certain cases, but this requires sizing the
___________________________________________________________________________________________________
Copyrights Reserved Page 6 of 27
table structure with respect to the page size. The locking mechanism can be
bypassed by setting the isolation level, to allow data to be read from
uncommitted transactions.
Oracle
Transactions are written to the redo log buffer, where they advance to the
redo logs, data file buffer, and data files. When a rollback occurs, block
images are discarded from the redo log buffer; as the previous block data is
held in the rollback segment blocks. Committed transactions are promoted
to the archive logs. Archive logs are used to restore the data in the event of
a hardware failure. A checkpoint operation flushes all updated (committed)
memory blocks from the log buffer and database buffer pool.
During an update transaction, record locking provides prevents data block
collisions from occurring. Access to the "before" image of the record(s) is
made available during this time, which reduces contention. This is a
patented record locking mechanism.
Backup Procedures
Sybase:
Oracle:
Previous to Oracle 8, the only way to back up the database was through a
"cold" backup. This involved shutting down the Oracle instance, backing up
the data files, and restarting upon completion.
Recovery Procedures
Sybase:
A "load database" command loads the designated database with the named
dump file.Subsequent "load transaction" commands can then be issued to
load multiple transaction dump files.
___________________________________________________________________________________________________
Copyrights Reserved Page 7 of 27
Oracle:
Oracle:
Oracle is shipped with several built-in accounts: system, internal, and sys.
Operating system authentication is required in order for a login to be
created with similar privileges. After a login is created, access is then
granted to the tables within schemas as needed.
Database Creation
Sybase:
Oracle:
Storage Concepts
Sybase:
Oracle 9i,10g does support semantic partitioning, by list, range, hash, hash
range, and composite.
Transact-SQL
Sybase:
___________________________________________________________________________________________________
Copyrights Reserved Page 9 of 27
Oracle:
Triggers
Sybase:
Sybase ASE supports insert, update, and delete triggers. Triggers are fired
after the transaction starts, and have the capability to roll back if required.
Images of the 'before' and 'after' records are visible within the trigger.
Oracle:
Oracle supports select, insert, update, and delete triggers. Triggers can be
set to fire 'before' or 'after' a transaction. NEW and OLD aliases are used to
refer to the before and after images of the data. Oracle also supports DDL
Event Triggers.
Sybase ASE does not support analytic functions (median, n-tile, lead/lag,
over partitions) at the moment; Sybase IQ, the data warehouse product,
does support most analytic functions.
Oracle:
Oracle 10 does support analytic functions like median, n-tile, and lead/lag,
over partitions.
___________________________________________________________________________________________________
Copyrights Reserved Page 10 of 27
Flat File Processing
Sybase:
Sybase ASE includes the BCP utility (Bulk-Copy) which can import or export
data via flat files. "Fast" mode imports are achieved by simply removing the
indexes (and triggers) from the target table.
Oracle:
Oracle includes the SQLLDR utility (SQL Loader) which can import via flat
files.” Direct" mode imports are achieved by simply removing indexes (and
triggers)from the target table, and specifying direct=yes at command line.
There is no Oracle utility for exporting data to a flat file; sqlplus must be
used to spool the data to a file.
servers.
Oracle:
Oracle has always been known for its speed and performance. Oracle 10
supports over 15,000 active user connections. The patented record locking
scheme made it an attractive candidate for scanned applications marketed
by PeopleSoft and the like. The ability to turn transaction logging on and off
at will allows Oracle squeak by competitors during benchmark analysis runs.
Price
Sybase:
Price per seat is average, compared to other vendors; Sybase ASE is the
leader in lowest transaction cost, with the best performance, among the
leading enterprise database vendors.
Oracle:
ISQL is the interactive query tool used with Sybase.t is useful for entering
queries and stored procedures.
Sybase Central is shipped with Sybase ASE. It offers a good interface for
performing basic database tasks. The "best of breed"product in this
category is DB-Artisan by Embarcadero Technologies. Sybase recently
released Workspace, an Eclipse based SQL development environment,
which features a stored procedure debugger and graphical SQL creator. For
development, Sybase Inc. offers Workspace Powerbuilder,Powerdesigner,
Power J and its "Studio" line products. Powerbuilder remains the most
robust, straightforward, and practical choice for windows development,
supporting many other RDBMs in addition to Sybase ASE.
Oracle:
SQL-Plus is the interactive query tool used with Oracle; it is useful for
entering queries and stored procedures. Complex reporting capabilities are
available for those willing to learn SQL-Plus extensions.
Oracle Enterprise ships with Enterprise Manager, a full featured front end to
the intricacies of Oracle. The main areas of the system (security, storage,
schemas) are managed by totally separate applications, which is
cumbersome at times.
SYSTEM DATABASES:
___________________________________________________________________________________________________
Copyrights Reserved Page 12 of 27
Master Database
Model database
A template for new user databases. The build master program and
the install model script create model when SQL Server is installed.
Each time the create database command is issued; SQL Server
makes a copy of model and extends it to the size requested, if
necessary.
It is house for those items you want available across all databases
(rules, defaults, user defined data types)
SYBSYSTEMPROCS
Stored Procedure
___________________________________________________________________________________________________
Copyrights Reserved Page 13 of 27
System procedure
Stored procedure:
System procedures:
Temporary database
P-T-T: This table exists in the tempdb until server gets restart or
shutdown
T-T-T: This table exists in the tempdb only for the session or Sp in which
they created, all sever go for T-T-T creation
System tables
One of the data dictionary tables. The system tables keep track of
___________________________________________________________________________________________________
Copyrights Reserved Page 14 of 27
information about the SQL Server as a whole and about each user
database. The Master Database contains some system tables that are
not in user databases.
Syscomments syslogins
Sysindexes sysdatabases
Sysobjects sysservers
SYBASE TOOLS:
There are three major tools provided by sybase for administering
maintaining, and accessing the sql server.
They are
Bcp
Isql
defncopy
SQL
___________________________________________________________________________________________________
Copyrights Reserved Page 15 of 27
BCP
DEFNCOPY
___________________________________________________________________________________________________
Copyrights Reserved Page 16 of 27
Session Manager :Provides manageability of database sessions including
user lock which allow the user to monitor and kill sessions.
Performance tunings
Versions
sample interview qstns
Exercises on query
session split+
It has a New roll back records, optimizer changes & trace flag 326.
___________________________________________________________________________________________________
Copyrights Reserved Page 17 of 27
___________________________________________________________________________________________________
Copyrights Reserved Page 18 of 27
2. Getting started with the sybase server.
___________________________________________________________________________________________________
Copyrights Reserved Page 19 of 27
3.After that we have to type the path followed by user
name and password
Path:cd /opt/sybase
source SYBASE.sh
___________________________________________________________________________________________________
Copyrights Reserved Page 20 of 27
Basic Commands:
We have few very basic commands. The commands are follows
a) Create :
It is used to create a table for inserting the records. The syntax is follows
b)Insert :
c) Update:
It is used to modify (add or modify) rows in the table. The syntax is follows
d)Alter :
e)Delete :
f) Views :
It is a logical way of looking at the physical data located in the tables. The syntax
is follows.
___________________________________________________________________________________________________
Copyrights Reserved Page 21 of 27
g) Rules:
rulename,'tablename.columnname'
h) Stored Procedures:
as
For eg:
begin
return 0
end
___________________________________________________________________________________________________
Copyrights Reserved Page 22 of 27
i)Triggers :
It is an integral part of statement that fires when you do insert ,update and
delete operation. The syntax is follows
as
sql statements
[return]
j)Cursors :
It is a pointer that identifies a specific working row within a set. The syntax
of the declare cursor statement is :
For eg:
___________________________________________________________________________________________________
Copyrights Reserved Page 23 of 27
4. While ascending and descending orders in the same query for different
view as security
temporary and permanent temporary tables
check constraints
Default
View
___________________________________________________________________________________________________
Copyrights Reserved Page 24 of 27
Rule
7. What are the types of index? Explain the leaf structure of the index.
DATABASE SCHEMA
The relation "Product" shows the maker, model number, and type (pc, laptop, or
printer). It is assumed that model numbers are unique for all the makers and
product types. Each model number specifying pc in the relation "PC" is
characterized by speed (of the processor in MHz), total amount of RAM (in Mb),
hard disk drive capacity (in Gb), CD ROM speed (for example, '4x'), and the price.
The relation "Laptop" is similar to that one of PCs except for the CD ROM speed,
which is replaced by the screen size (in inches). For each printer model in the
relation "Printer" it is told whether the printer is color or not (color attribute is 'y'
for color printers; otherwise it is 'n'), printer type (laser, jet, or matrix), and the
price.
___________________________________________________________________________________________________
Copyrights Reserved Page 25 of 27
1. Find the model number, speed and hard drive capacity for all the PCs with
2. Point out the maker and speed of the laptops having hard drive capacity more
or equal to 10 Gb.
3. Find the model number, speed and hard drive capacity of the PCs having 12x
CD and prices less than $600 or having 24x CD and prices less than $600.
4. Find the model number, RAM and screen size of the laptops with prices over
$1000.
5. Find out the makers that sale PCs but not laptops.
6.Find out the models and prices for all the products (of any type) produced by
maker B.
___________________________________________________________________________________________________
Copyrights Reserved Page 26 of 27
Book: Sybase SQL Server 11
by
Ray Rankins
Jeffrey R. Garbus
David Solomon
Bennett Wm.McEwan
___________________________________________________________________________________________________
Copyrights Reserved Page 27 of 27