<?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>Sybase Guru &#187; Sybase</title>
	<atom:link href="http://sybaseguru.freetimelabs.com/category/sybase/feed/" rel="self" type="application/rss+xml" />
	<link>http://sybaseguru.freetimelabs.com</link>
	<description>All about Sybase DB</description>
	<lastBuildDate>Sat, 13 Jun 2009 08:44:38 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>SYBASE ADAPTIVE SERVER ENTERPRISE</title>
		<link>http://sybaseguru.freetimelabs.com/2009/05/sybase-adaptive-server-enterprise/</link>
		<comments>http://sybaseguru.freetimelabs.com/2009/05/sybase-adaptive-server-enterprise/#comments</comments>
		<pubDate>Wed, 27 May 2009 07:18:09 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Sybase]]></category>

		<guid isPermaLink="false">http://sybaseguru.freetimelabs.com/?p=129</guid>
		<description><![CDATA[Release 12.5 GA and above
INDEX:
I&#8230;.. .ASE Overview

II&#8230;..System Databases and Tables

III&#8230;.Transact SQL

IV&#8230;.Transactions
V&#8230;&#8230;Isolation Levels
VI&#8230;..Locking

VII&#8230;ASE Supported Platforms

VIII..ASE Utilities

IX&#8230;..Component Integration Services (CIS)

X&#8230;&#8230;New Features – ASE 15

XI&#8230;.ASE Resources

XII&#8230;SYBASE Data Server &#38; Integration Products
For Details of the INDEX  refer the next pages  w.r .to each INDEX.

]]></description>
			<content:encoded><![CDATA[<p><strong>Release 12.5 GA and above</strong></p>
<p style="text-align: left;"><strong><span style="text-decoration: underline;">INDEX:</span></strong></p>
<p style="text-align: left;"><strong>I&#8230;.. .ASE Overview<br />
</strong></p>
<p style="text-align: left;"><strong>II&#8230;..System Databases and Tables<br />
</strong></p>
<p style="text-align: left;"><strong>III&#8230;.Transact SQL<br />
</strong></p>
<p style="text-align: left;"><strong>IV&#8230;.Transactions</strong></p>
<p style="text-align: left;"><strong>V&#8230;&#8230;Isolation Levels</strong></p>
<p style="text-align: left;"><strong>VI&#8230;..Locking<br />
</strong></p>
<p style="text-align: left;"><strong>VII&#8230;ASE Supported Platforms<br />
</strong></p>
<p style="text-align: left;"><strong>VIII..ASE Utilities<br />
</strong></p>
<p style="text-align: left;"><strong>IX&#8230;..Component Integration Services (CIS)<br />
</strong></p>
<p style="text-align: left;"><strong>X&#8230;&#8230;New Features – ASE 15<br />
</strong></p>
<p style="text-align: left;"><strong>XI&#8230;.ASE Resources<br />
</strong></p>
<p style="text-align: left;"><strong>XII&#8230;SYBASE Data Server &amp; Integration Products</strong></p>
<p style="text-align: left;"><strong>For Details of the INDEX  refer the next pages  w.r .to each INDEX.<br />
</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://sybaseguru.freetimelabs.com/2009/05/sybase-adaptive-server-enterprise/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>III. TRANSACT SQL.</title>
		<link>http://sybaseguru.freetimelabs.com/2009/05/iii/</link>
		<comments>http://sybaseguru.freetimelabs.com/2009/05/iii/#comments</comments>
		<pubDate>Wed, 27 May 2009 05:49:20 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Sybase]]></category>

		<guid isPermaLink="false">http://sybaseguru.freetimelabs.com/?p=118</guid>
		<description><![CDATA[III. TRANSACT SQL .

  Data types
 List system objects  and attributes
 Creating a table
 Altering a table
 Table creation &#8211; Alternatives
 Indexes
 Clustered vs. non-clustered indexes
 Creating constraints
 Defaults
 Table partitioning
 Object permissions
 Binding Rules
 Modifying a Column
 Moving an object
 Views
 Stored Procedures
 Triggers

Datatypes:–
Note:–Table with contents to be drawn……..
.
.
.
.
.
.
.
.
List System Objects &#38; Attributes:–

 [...]]]></description>
			<content:encoded><![CDATA[<p><strong>III. TRANSACT SQL .</strong></p>
<ul>
<li> <strong> Data types</strong></li>
<li><strong> List system objects  and attributes</strong></li>
<li><strong> Creating a table</strong></li>
<li><strong> Altering a table</strong></li>
<li><strong> Table creation &#8211; Alternatives</strong></li>
<li><strong> Indexes</strong></li>
<li><strong> Clustered vs. non-clustered indexes</strong></li>
<li><strong> Creating constraints</strong></li>
<li><strong> Defaults</strong></li>
<li><strong> Table partitioning</strong></li>
<li><strong> Object permissions</strong></li>
<li><strong> Binding Rules</strong></li>
<li><strong> Modifying a Column</strong></li>
<li><strong> Moving an object</strong></li>
<li><strong> Views</strong></li>
<li><strong> Stored Procedures</strong></li>
<li><strong> Triggers</strong></li>
</ul>
<p><strong>Datatypes:–</strong></p>
<p>Note:–Table with contents to be drawn……..</p>
<p>.</p>
<p>.</p>
<p>.</p>
<p>.</p>
<p>.</p>
<p>.</p>
<p>.</p>
<p>.</p>
<p><strong>List System Objects &amp; Attributes:–</strong></p>
<ul>
<li> List all table names for current database</li>
</ul>
<p>select name<br />
from sysobjects where type = ‘U’<br />
go<br />
OR<br />
use system SP sp_tables</p>
<ul>
<li>List all trigger names for current database</li>
</ul>
<p>select name<br />
from sysobjects where type = ‘T’<br />
go</p>
<ul>
<li>List all procedure names for current database</li>
</ul>
<p>select name<br />
from sysobjects where type = ‘P’<br />
go</p>
<ul>
<li> Display column definitions and indexes for emp table</li>
</ul>
<p>sp_help emp<br />
go</p>
<ul>
<li>Display space used for emp table</li>
</ul>
<p>sp_spaceused emp<br />
go</p>
<ul>
<li> Display source code for emp_proc</li>
</ul>
<p>sp_helptext emp_proc<br />
go<br />
<strong><br />
Creating a table:–</strong></p>
<ul>
<li> Defines each column in the table.</li>
</ul>
<ul>
<li> The table definition provides the column name, datatype and specifies how each column handles null values.</li>
</ul>
<ul>
<li>Specifies which column, if any, has the IDENTITY property.</li>
</ul>
<ul>
<li> Defines column-level integrity constraints and table-level integrity constraints. Each table definition can have multiple constraints per column and per table.</li>
</ul>
<p>Design of Table for creating a table :&#8211;</p>
<ul>
<li> Decide what columns you need in the table, the datatype, length, precision, and scale, for each column.</li>
</ul>
<ul>
<li> Create any new user-defined datatypes before you define the table where they are to be used.</li>
</ul>
<ul>
<li> Decide which column, if any, should be the IDENTITY column.</li>
</ul>
<ul>
<li> Decide which columns should and should not accept null values.</li>
</ul>
<ul>
<li> Decide what integrity constraints or column defaults, if any, you need to add to the columns in the table. This also includes rules, indexes, and triggers to enforce data integrity.</li>
</ul>
<ul>
<li> Decide whether you need defaults and rules, and if so, where and what kind. Consider the relationship between the NULL and NOT NULL status of a column and defaults and rules.</li>
</ul>
<ul>
<li> Decide what kind of indexes you need and where. Indexes are discussed later</li>
</ul>
<p>Examples of creating a table:–</p>
<p><strong>1.)</strong><br />
create table emp (<br />
emp_id    numeric(8,0)  identity,<br />
emp_name    varchar(50)   not null,<br />
salary    money         not null,<br />
dept_cd   char(3)       not null,<br />
fax_no    integer       null<br />
)<br />
go</p>
<p><strong>2.)</strong><br />
create table invoice (<br />
invoice_id     numeric(8,0)  identity,<br />
sales_rep_id   numeric(8,0)  not null,<br />
date           smalldatetime not null,<br />
comment        varchar(255)  null )<br />
on data_seg2<br />
go</p>
<p><strong>3.)</strong><br />
create table  err_cd (<br />
err_id       integer       not null,<br />
err_desc     varchar(60)   not null,<br />
constraint pk_err_cd primary key clustered (err_id)<br />
)<br />
go</p>
<p><strong>Altering a table:&#8211;</strong></p>
<p>Alter table examples<br />
- alter table employee add cell_no numeric(10) null<br />
go<br />
- alter table employee drop constraint     &#8216;emp_dept_constr&#8217;<br />
go<br />
Default<br />
alter table charge_item replace price_overridable_ind default 0<br />
go</p>
<p>Change column name (quotes required)<br />
sp_rename &#8216;emp.dept&#8217;,dept_name<br />
go</p>
<p><strong>Table Creation &#8211; Alternatives:&#8212;-</strong></p>
<p>If you already have a table and would like to create another with the same column definitions, use ‘select into’<br />
select * into my_copy from source_table</p>
<p>To capture a subset of the columns, replace * with names<br />
select col1, col2 into my_copy from source_table</p>
<p>The above also copy the data to the new table</p>
<p>To skip the data copy, use an ‘empty where clause’<br />
select * into my_copy<br />
from source_table<br />
where 1=0</p>
<p>Default rules are not copied to the new table<br />
Indexes are not created on the new table<br />
The database option<br />
“select into/bulkcopy/pllsort” must be on in this database to use ‘select into’</p>
<p><strong>Indexes:&#8212;</strong></p>
<ul>
<li>create unique clustered index emp_idx</li>
</ul>
<p>on emp (emp_id)<br />
go</p>
<ul>
<li>create index emp_name_idx</li>
</ul>
<p>on emp (emp_name)<br />
go</p>
<ul>
<li>create unique clustered index pk_invoice_data on invoice_data  with  sorted_data on segment1</li>
</ul>
<p>go /* Creates sorted index on a segment */</p>
<ul>
<li>Clustered</li>
<li>Non-clustered</li>
</ul>
<p>Typically,<br />
Clustered index will be created on the primary key of a table</p>
<p>Non-clustered indexes are used where needed.</p>
<p><strong>Clustered Vs Non-clustered indexes:&#8212;</strong></p>
<p><strong>Clustered indexes</strong>:</p>
<ul>
<li> Records in table are sorted physically by key values</li>
<li> Only one clustered index per table</li>
<li> Higher overhead on inserts, if re-org on table is required</li>
<li> Best for queries requesting a range of records</li>
<li> Index must exist on same segment as table</li>
</ul>
<p><strong>Non-clustered indexes:</strong></p>
<ul>
<li> Leaves are stored in b-tree</li>
<li> Lower overhead on inserts, vs. clustered</li>
<li> Best for single key queries</li>
<li> Last page of index can become a &#8216;hot spot&#8217;</li>
<li> Clustered indexes are sorted physically only upon creation if a table is created with &#8220;lock datapages&#8221; or &#8220;lock datarows&#8221; . The clustered index, thereafter behave as a non-clustered index</li>
</ul>
<p><strong>Creating a constraint:&#8212;</strong></p>
<p>Constraints are used to define primary keys, enforce uniqueness, and to describe foreign key relationships. By default, indexes are created upon creation of unique or primary key constraints.</p>
<ul>
<li>Primary key for the employee table<br />
alter table emp add constraint<br />
emp_constr primary key(emp_id)<br />
go</li>
</ul>
<ul>
<li>Add unique requirement for invoice table<br />
alter table invoice add constraint<br />
inv_constr unique nonclustered(cust_id,inv_date)<br />
go</li>
</ul>
<ul>
<li>Add foreign key for relationship between invoice and emp tables<br />
alter table invoice add constraint inv_fk_emp<br />
foreign key (sales_rep_id)<br />
references emp(emp_id)<br />
go</li>
</ul>
<p><strong>Defaults:&#8211;</strong></p>
<ul>
<li>Creating Defaults<br />
create default def_highsal as 15000<br />
go</li>
</ul>
<ul>
<li>Binding defaults<br />
sp_bindefault def_highsal,&#8217;emp.salary&#8217;<br />
go</li>
</ul>
<ul>
<li>Creating your own custom defaults has an advantage that the name of the default can be chosen to reflect the application/functionality.</li>
</ul>
<p><strong>Table Partitioning:&#8211;</strong><br />
Insert performance on partitioned tables is improved, as multiple &#8216;entry points&#8217; (last page entries) are created. Partitioned tables require slightly more disk space and small bit of additional memory.</p>
<ul>
<li>Create partitions for a table</li>
</ul>
<p>alter table invoice &#8212; creates 3 partitions on invoice table<br />
partition 3<br />
go</p>
<ul>
<li> Tables which span multiple segments</li>
</ul>
<p>Tables containing large amounts of data (&gt; 2 GB) need to be spread across several devices, using sp_placeobject. Note that this procedure affects only         future operations &#8211; if a table load of more than 2 GB is to be performed, it would have to be split into two or more stages.</p>
<ul>
<li>Command &#8211; Span Multiple Segments</li>
</ul>
<p>sp_placeobject &#8216;data_seg2&#8242;,&#8217;invoice&#8217;<br />
go</p>
<p><strong>Object Permissions:&#8211;</strong></p>
<p>Object security is fairly straightforward and is handled using the ‘grant’ Transact SQL statement.</p>
<ul>
<li>grant all on emp to Srinath</li>
</ul>
<p>go</p>
<ul>
<li> grant select on emp to Prashanth</li>
</ul>
<p>go</p>
<ul>
<li> grant update on emp to Prashanth</li>
</ul>
<p>go</p>
<ul>
<li> revoke select on emp from Prashanth</li>
</ul>
<p>go</p>
<p>Stored procedure security allows you to grant access on a business logic basis. For example, if you had a stored proc that updated the invoice table and selected data from the customer table, you could grant the execute privilege on the stored proc, and you&#8217;re done. The user would be able to run the procedure to update/select from the tables, but will not get to the tables directly.</p>
<ul>
<li>grant execute</li>
</ul>
<p>on proc_upd_invoice to Srinath<br />
go</p>
<p><strong>Binding Rules to Columns:&#8211;</strong><br />
Default values for columns can be specified at the time a table is created, or afterwards via the modify command.</p>
<p>Examples<br />
create table emp (<br />
emp_id   integer  not null,<br />
emp_name varchar(50) null,<br />
salary   money    default 15000<br />
)<br />
go</p>
<p>alter table emp replace salary default 19000<br />
go</p>
<p><strong>Modifying Column:&#8211;</strong></p>
<p>To modify/alter a column type you need to be “dbo” and have select into option enabled, in the database defaults.</p>
<p>create table emp (<br />
emp_id   integer  not null,<br />
emp_name varchar(50)  null,<br />
salary   money    default 0<br />
)<br />
go</p>
<p>/* make the name column longer */<br />
alter table emp modify emp_name varchar(100) not null<br />
go</p>
<p>/* rename the column */<br />
sp_rename &#8216;emp.emp_name’, name<br />
go</p>
<p><strong>Move objects to segments:&#8211;</strong></p>
<p>When databases contain more segments, it is often necessary to move tables between segments.</p>
<p>Examples</p>
<ul>
<li> Move a table entirely to a new segment</li>
</ul>
<p>drop index &#8216;employee.idx_employee&#8217;<br />
go<br />
create clustered index on emp (emp_id) on new_seg<br />
go</p>
<ul>
<li>Leaving the table in the existing location but future allocations go to the new segment</li>
</ul>
<p>sp_placeobject new_seg , &#8216;emp&#8217;<br />
go</p>
<ul>
<li>To leave a table in the existing location and use a new segment for future allocations of the text column (emp_notes):</li>
</ul>
<p>sp_placeobject new_seg, &#8216;emp.emp_notes&#8217;</p>
<p>go</p>
<p><strong>Views:&#8211;</strong><br />
Views offer an alternative way to look at data and can also be used to enforce security by limiting the data that is seen by users.</p>
<ul>
<li>Create Views</li>
</ul>
<p>create view emp_view<br />
as select emp_id, emp_name from emp<br />
where emp_id &gt; 1 and emp_id &lt; 101</p>
<ul>
<li> Retrieve data via Views</li>
</ul>
<p>select * from emp_view</p>
<ul>
<li>Updates on views are possible but there are restrictions. Some update restrictions are:</li>
</ul>
<ol>
<li> Views created with computed columns in the view definition.</li>
<li> Underlying table objects having NOT NULL columns.</li>
<li> Check option used for creation of views.</li>
<li> Deletes are not allowed on views created with multiple objects.</li>
</ol>
<ul>
<li> The data accessed via a view must require permissions irrespective of the permissions existing in the underlying tables that are used to create the view. The data in the underlying tables that is not included in the view are not visible to the users.</li>
</ul>
<ul>
<li>Advantages:</li>
</ul>
<ol>
<li> Provide the data to view that is of interest to a particular set of users.</li>
<li> In cases where joins must be used in queries frequently, create a view with the underlying objects and the joins once and use select * from view</li>
<li> Display different data to different target users with multiple views created using the same underlying data.</li>
</ol>
<p><strong>Stored Procedures:&#8211;</strong></p>
<p>Stored procedures are compiled versions of SQL statements. Performance benefits are significant as network traffic is reduced, and the optimizer does not need to re-parse the code.</p>
<p>Stored Procedures are classified into:</p>
<ul>
<li> System Stored Procedures – Defined by SYBASE and delivered as part of ASE.</li>
</ul>
<p>Examples:<br />
- sp_who –Provides information on users on ASE<br />
- sp_help – Provides a information/listing of all objects in the current database.<br />
All of the System Stored Procedures start with “sp_” and are located in the ‘sybsystemprocs’ system database</p>
<ul>
<li>User Stored Procedures – Defined by the users of ASE in a designated user database.</li>
</ul>
<ul>
<li>Stored procedure to retrieve</li>
</ul>
<p>create procedure proc_rtv_invoice<br />
(@inv_id numeric(8,0) ) as<br />
select inv_id, inv_date, salesrep_emp_id<br />
from invoice<br />
where inv_id = @inv_id<br />
return<br />
go</p>
<ul>
<li>Execute the stored procedure</li>
</ul>
<p>exec proc_rtv_invoice 325<br />
go</p>
<p><strong>Triggers:&#8211;</strong><br />
Trigger is a special type of SP that gets executed automatically when any DML operation takes place on a table.</p>
<ul>
<li>Triggers are used to enforce referential integrity.</li>
</ul>
<ul>
<li> Triggers are used to cascade changes to related tables.</li>
</ul>
<ul>
<li> Triggers can be used to apply complex restrictions than that enforced using rules.</li>
</ul>
<ul>
<li> Trigger can perform analysis before and after changes to the table.</li>
</ul>
<ul>
<li>Triggers cannot have the following:</li>
</ul>
<ol>
<li> create and drop commands.</li>
<li>alter table, alter database, truncate table.</li>
<li>Load database and transactions.</li>
<li>Grant and revoke statements.</li>
<li>update statistics</li>
<li>reconfigure</li>
<li>disk init, disk mirror, disk refit, disk reinit, disk remirror, disk unmirror</li>
<li>select into</li>
</ol>
<ul>
<li>Trigger creation</li>
</ul>
<p>create trigger emp_trigger<br />
on emp<br />
for insert, update, delete<br />
as</p>
<ul>
<li> Trigger Example</li>
</ul>
<p>create trigger emp_trigger<br />
on emp<br />
for delete<br />
as<br />
delete payment<br />
from payment, deleted<br />
where payment.empid = deleted.empid</p>
]]></content:encoded>
			<wfw:commentRss>http://sybaseguru.freetimelabs.com/2009/05/iii/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>II. SYSTEM DATABASES AND TABLES.</title>
		<link>http://sybaseguru.freetimelabs.com/2009/05/ii/</link>
		<comments>http://sybaseguru.freetimelabs.com/2009/05/ii/#comments</comments>
		<pubDate>Wed, 27 May 2009 05:38:07 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Sybase]]></category>

		<guid isPermaLink="false">http://sybaseguru.freetimelabs.com/?p=114</guid>
		<description><![CDATA[II.   SYSTEM DATABASES AND TABLES.
When ASE is installed following databases are installed.
* master
* model
* sybsystemprocs
* tempdb
Optional databases that can be installed are
* sybsecurity
* sybsystemdb
* dbcc
* sybdiag
* pubs2  and pubs3
ASE  databases:
master database:–
Controls the operation of ASE and stores the information of user databases and devices on the ASE server
No.… Information…………………………………………&#8230;.System Table
1        User accounts :……………………………………………….syslogins
2       Remote user [...]]]></description>
			<content:encoded><![CDATA[<p><strong>II.   SYSTEM DATABASES AND TABLES.</strong></p>
<p>When ASE is installed following databases are installed.</p>
<p>* master<br />
* model<br />
* sybsystemprocs<br />
* tempdb</p>
<p>Optional databases that can be installed are</p>
<p>* sybsecurity<br />
* sybsystemdb<br />
* dbcc<br />
* sybdiag<br />
* pubs2  and pubs3</p>
<p><strong>ASE  databases:</strong></p>
<p><strong>master database:–</strong></p>
<p>Controls the operation of ASE and stores the information of user databases and devices on the ASE server</p>
<p>No.… Information…………………………………………&#8230;.System Table<br />
1        User accounts :……………………………………………….syslogins</p>
<p>2       Remote user accounts :…………………………………… sysremotelogins</p>
<p>3      Remote servers that this servercan interact with:….sysservers<br />
4      Ongoing processes :………………………………………….sysprocesses<br />
5      Configurable environment variables :………………….sysconfigures<br />
6      System error messages:…………………………………….sysmessages<br />
7      Databases on Adaptive Server:…………………………..sysdatabases<br />
8     Storage space allocated to each database:……………..sysusages<br />
9    Tapes and disks mounted on the system:……………… sysdevices<br />
10    Active locks:…………………………………………………..syslocks<br />
11    Character sets:………………………………………………..syscharsets<br />
12    Languages:…………………………………………………….syslanguages<br />
13    Users who hold server-wide roles:……………………. sysloginroles<br />
14    Server roles:………………………………………………….syssrvroles<br />
15    Adaptive Server engines that are online:…………….sysengines</p>
<p><strong>model database:–-</strong></p>
<p>All new user databases use model database as a template database. ASE copies this database whenever a new database is created and extends the space of the new user database as specified in the ‘create database’ command Use sp_tables system SP to get the list of system tables in model database.</p>
<p><strong>sybsystemprocs:-–</strong></p>
<p>All ASE system stored procedures are stored in this database.</p>
<p><strong>tempdb :–-</strong></p>
<p>This is a temporary database used by ASE. “tempdb” database is used to store temporary tables and other working structures.<br />
tempdb is installed by default during ASE installation.<br />
Multiple tempdb(s) can be created based on need.<br />
Optional databases::</p>
<p><strong>sybsecurity :–-</strong></p>
<p>This database contains the audit system to audit database users activity on ASE.<br />
<strong>sysbsystemdb:-–</strong></p>
<p>This is used by ASE to store information of distributed transactions and provides transaction coordination for remote servers using RPCs and CIS services.</p>
<p><strong>dbcc :-–</strong></p>
<p>This database is used to store configuration information of target database operation activity and results of the operation from ‘dbcc checkstorage’</p>
<p><strong>sybdiag :–-</strong></p>
<p>This database may be created and used by SYBASE Technical Support to troubleshoot the system. The database holds diagnostic information.</p>
<p><strong>pubs2 and pub3 :-–</strong></p>
<p>These are learning databases provided by SYBASE.</p>
]]></content:encoded>
			<wfw:commentRss>http://sybaseguru.freetimelabs.com/2009/05/ii/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>I. Adaptive Server Enterprise(ASE) Overview.</title>
		<link>http://sybaseguru.freetimelabs.com/2009/05/adaptive-server-enterprise-overview/</link>
		<comments>http://sybaseguru.freetimelabs.com/2009/05/adaptive-server-enterprise-overview/#comments</comments>
		<pubDate>Sat, 16 May 2009 10:16:45 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Sybase]]></category>

		<guid isPermaLink="false">http://sybaseguru.freetimelabs.com/?p=97</guid>
		<description><![CDATA[I. A S E  OVERVIEW.

ASE Server
Memory Model
Transaction Processing
Backup Procedures
Recovery Procedures
ASE Logins
ASE Groups
Security and Account Setup
Database Creation
Storage Concepts
Transact SQL
Transact SQL Extensions

ASE Server:&#8211;
ASE server consists of

 Two processes, data server and backup server.
 Devices house the databases. Master database contains system and configuration data.
 Configuration file contains the server attributes.
 The logical page size of the server [...]]]></description>
			<content:encoded><![CDATA[<p><strong>I. <span style="text-decoration: underline;">A S E  OVERVIEW.</span></strong></p>
<ul>
<li><strong>ASE Server</strong></li>
<li><strong>Memory Model</strong></li>
<li><strong>Transaction Processing</strong></li>
<li><strong>Backup Procedures</strong></li>
<li><strong>Recovery Procedures</strong></li>
<li><strong>ASE Logins</strong></li>
<li><strong>ASE Groups</strong></li>
<li><strong>Security and Account Setup</strong></li>
<li><strong>Database Creation</strong></li>
<li><strong>Storage Concepts</strong></li>
<li><strong>Transact SQL</strong></li>
<li><strong>Transact SQL Extensions</strong></li>
</ul>
<p><strong>ASE Server:&#8211;</strong></p>
<p>ASE server consists of</p>
<ul>
<li> Two processes, data server and backup server.</li>
<li> Devices house the databases. Master database contains system and configuration data.</li>
<li> Configuration file contains the server attributes.</li>
<li> The logical page size of the server can vary between 2K to 16K (2K, 4K, 8K and 16K). 2K page size is the default.</li>
</ul>
<p><strong>Memory Model:&#8211;</strong></p>
<p>The ASE executable runs as a single process within the OS. Multiple users connect to the database. Only one process is managed by the OS. Each Sybase database connection requires memory.</p>
<p><img class="aligncenter size-full wp-image-102" title="memory-model-ase" src="http://sybaseguru.freetimelabs.com/wp-content/uploads/2009/05/memory-model-ase.png" alt="memory-model-ase" width="438" height="343" /></p>
<ul>
<li>ASE executable or the dataserver executable resides in the program area.</li>
<li>Cache stores both Data Cache and Procedure Cache. Both have independent memory allocation.</li>
<li>The data cache stores recently fetched pages from the database device.</li>
<li>The procedure cache contains information of optimized sql calls.</li>
</ul>
<p><strong>Transaction Processing:&#8211;</strong></p>
<ul>
<li>Transactions are written to the data cache first and then they advance to the transaction log and database device.</li>
<li>Pages are discarded from the data cache on rollback.</li>
<li>Transaction logs are used to restore data in event of a hardware failure.</li>
<li>Checkpoint operation flushes all updated/committed memory pages to their respective tables.</li>
</ul>
<ul>
<li>Transaction logging is required for all databases. Image (blob) fields may be exempt.</li>
<li>During update transaction, the data page(s) containing the row(s) are locked.</li>
<li>Row level record locking is available and can be enabled. To facilitate this, the table structures may need to be tuned.</li>
</ul>
<p><strong>Backup Procedures :&#8211;<br />
</strong></p>
<ul>
<li>Backup procedures are facilitated by the backup server.</li>
<li>Backup procedure is carried out using &#8220;dump database&#8221; operation.</li>
<li>Backup operation can be performed when the database is on-line or offline.</li>
<li>Transactions can be dumped using &#8220;dump transaction&#8221; commands.</li>
</ul>
<p><strong>Recovery Procedures:&#8211;</strong></p>
<ul>
<li>Load procedures are facilitated by the backup server.</li>
<li>Load procedure is carried out using &#8220;load database&#8221; operation.</li>
<li>Load operation loads the designated database with the named dump file.</li>
<li>Transactions can be loaded using &#8220;load transaction&#8221; commands.</li>
<li>Transaction commands can then be issued to load multiple transaction dump files.</li>
</ul>
<p><strong>ASE Logins:&#8211;</strong></p>
<p>Each Adaptive Server user must have a<br />
login account. Characteristics of Login accounts</p>
<ul>
<li>A login name is unique on the server</li>
<li>Password is required to login</li>
<li>A default database (optional) is assigned.</li>
<li>A default language (optional).</li>
<li>A full name (optional).</li>
</ul>
<p><strong>ASE Groups:&#8211;</strong></p>
<ul>
<li>A group is created within a database.</li>
<li>The Database Owner is responsible for creating groups and assigning users to them.</li>
<li>A login/user is always a member of the “public” group, which includes all users on Adaptive Server.</li>
<li>The login/user can also belong to one other group.</li>
<li>Use sp_helpuser system stored procedure to find out what group the user belongs to.</li>
</ul>
<p><strong>Security and Account Setup:&#8211; </strong></p>
<ul>
<li>The initial login shipped with ASE is &#8220;sa&#8221; (system administrator).</li>
<li>The “sa” login has the role &#8220;sa_role&#8221; which is the super-user.</li>
<li>User logins are added at the server level.</li>
<li>The login is granted access to one or more databases by adding the login as a user of the respective database.</li>
</ul>
<ul>
<li>Access is granted to one or more tables and objects within a database.</li>
<li>A user in a database can be aliased as &#8220;dbo&#8221;.</li>
<li>“dbo” has all rights within a database.</li>
</ul>
<p><strong>Database Creation:&#8211;</strong></p>
<ul>
<li>Databases are initialized with the &#8220;create database&#8221; command.</li>
<li>Many databases can exist in one ASE server.</li>
<li>Tables are created within each database.</li>
<li>ASE databases can reside on one or more segments/devices.</li>
</ul>
<p><strong>Storage Concepts:&#8211;</strong></p>
<ul>
<li>Tables are stored in segments.</li>
<li>Segment is an area within a device with a name and a size. A segment/device is allocated for a database.</li>
<li>The transaction log is stored in its own segment, usually on a separate device.</li>
</ul>
<p><strong>Transact-SQL:&#8211;</strong></p>
<ul>
<li>Transact-SQL is a robust programming language created by SYBASE to access the database and the underlying data in the tables.</li>
<li>ANSI 89 and 92 compliant.</li>
<li>Used for managing ASE database and server(s).</li>
</ul>
<p><strong>Transact SQL Extensions:&#8211;</strong></p>
<ul>
<li>Any number of result sets can be returned to calling applications via SELECT statements.</li>
<li>Triggers and Stored procedures (System and User) are supported for writing SQL that are stored in a compiled format, which allows for automatic execution and faster execution of DML SQL code.</li>
<li>Cursors are supported for row by row processing.</li>
<li>Functions (System/Arithmetic/Date/String), Rules and Defaults are supported.</li>
<li>Temporary tables are supported, which allows customized private work tables to be created for complex processes.</li>
<li>Global and Local variable support.</li>
<li>Flow control statements (IF-ELSE, WHILE …).</li>
<li>Federal Information Processing Standards (fipsflagger).</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://sybaseguru.freetimelabs.com/2009/05/adaptive-server-enterprise-overview/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sybase Formatting Control Structures Standard</title>
		<link>http://sybaseguru.freetimelabs.com/2009/05/sybase-formatting-control-structures-standard/</link>
		<comments>http://sybaseguru.freetimelabs.com/2009/05/sybase-formatting-control-structures-standard/#comments</comments>
		<pubDate>Thu, 14 May 2009 10:42:48 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Sybase]]></category>

		<guid isPermaLink="false">http://sybaseguru.freetimelabs.com/?p=80</guid>
		<description><![CDATA[Control Structures
IF &#60;expression&#62; THEN
Executable_statements
ELSE
Executable_Statements

If executable statements are more than one statement then use BEGIN … END block for grouping the statements.
Recommendation:

One line space after executable statements
Executable statements should be indented atleast by 3  spaces.
If the executable statements inside an IF statement clause themselves contain another IF statement, then IF- ELSE and keywords should be indented [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Control Structures</strong></p>
<p><code>IF &lt;expression&gt; THEN<br />
Executable_statements<br />
ELSE<br />
Executable_Statements<br />
</code><br />
If executable statements are more than one statement then use <strong>BEGIN … END</strong> block for grouping the statements.</p>
<p>Recommendation:</p>
<ol>
<li>One line space after executable statements</li>
<li>Executable statements should be indented atleast by 3  spaces.</li>
<li>If the executable statements inside an IF statement clause themselves contain another IF statement, then IF- ELSE and keywords should be indented inside the enclosing IF statements for the inner IF should be indented further so that they are clearly with in the nested IF.</li>
</ol>
<p><strong>Formatting Loops</strong></p>
<p>Transact-SQL offers the <strong>WHILE</strong> loop. The <strong>GOTO</strong> statement can also be used for looping purposes.</p>
<p>Syntax:</p>
<p>WHILE Boolean_expression<br />
{sql_statement | statement_block}<br />
[BREAK] [CONTINUE]</p>
<p>Eg:<br />
<code>WHILE condition<br />
Executable_Statements<br />
END</code><br />
BREAK / CONTINUE can be used within the loop to encounter the exceptions.</p>
<p>Each loop has a loop boundary and a loop body. The loop body should be indented from the boundary. <strong></strong></p>
<p><strong></strong></p>
]]></content:encoded>
			<wfw:commentRss>http://sybaseguru.freetimelabs.com/2009/05/sybase-formatting-control-structures-standard/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Other Sybase Standard and Guidelines</title>
		<link>http://sybaseguru.freetimelabs.com/2009/05/other-sybase-standard-and-guidelines/</link>
		<comments>http://sybaseguru.freetimelabs.com/2009/05/other-sybase-standard-and-guidelines/#comments</comments>
		<pubDate>Thu, 14 May 2009 10:29:04 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Sybase]]></category>

		<guid isPermaLink="false">http://sybaseguru.freetimelabs.com/?p=77</guid>
		<description><![CDATA[Rule

Where possible, areas of common processing must be implemented by procedures. Note: Maximize re-use of pre-parsed statements.
For triggers of any complexity the detailed logic must be coded in procedures which are invoked from within the trigger body.
Object names must not be qualified with the owner name. Note: The statement cannot be run in another schema [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Rule</strong></p>
<ol>
<li>Where possible, areas of common processing must be implemented by procedures. <strong>Note:</strong> Maximize re-use of pre-parsed statements.</li>
<li>For triggers of any complexity the detailed logic must be coded in procedures which are invoked from within the trigger body.</li>
<li>Object names must not be qualified with the owner name. <strong>Note: </strong>The statement cannot be run in another schema if the owner is specified.</li>
<li>Whenever an explicit insert statement is used, the list of columns into which data is being inserted must be specified. <strong>Note:</strong> Insert statements must take the form <strong>INSERT INTO table (col1, col2) VALUES (val1,val2).</strong></li>
<li><strong>SELECT * FROM table_name</strong> should be avoided. You must explicitly name the columns being selected.</li>
<li>Transact SQL variables holding values for a particular column should be named <strong>@&lt;column_name&gt;.</strong></li>
<li>Stored procedure parameters should be named <strong>@p_&lt;parameter  name&gt;. </strong></li>
<li>A variable/parameter domain should be evident from the name.   <strong><br />
</strong></li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://sybaseguru.freetimelabs.com/2009/05/other-sybase-standard-and-guidelines/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sybase Naming Convention Standard</title>
		<link>http://sybaseguru.freetimelabs.com/2009/05/sybase-naming-convention-standard/</link>
		<comments>http://sybaseguru.freetimelabs.com/2009/05/sybase-naming-convention-standard/#comments</comments>
		<pubDate>Thu, 14 May 2009 10:09:08 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Sybase]]></category>

		<guid isPermaLink="false">http://sybaseguru.freetimelabs.com/?p=72</guid>
		<description><![CDATA[The naming convention for variables and constants is as follows:
1.  Program Structure
The following should be the templates used in T-SQL source code files.
Any T-SQL source file should have a file header of the following format (Header) followed by the body of the procedure. Since SQL server doesn’t support the concept of Packages the only type [...]]]></description>
			<content:encoded><![CDATA[<p>The naming convention for variables and constants is as follows:</p>
<p><strong>1.  Program Structure</strong></p>
<p><strong>The following should be the templates used in </strong><strong>T-SQL source code files.</strong></p>
<p>Any <strong>T-SQL</strong> source file should have a file header of the following format (Header) followed by the body of the procedure. Since SQL server doesn’t support the concept of Packages the only type of header is as follows:</p>
<p>/*<br />
**  (C) &lt;Year&gt;, Deutsche Bank Group</p>
<p>**  Name  :  (name of the package/procedure/function)</p>
<p>**  Description :</p>
<p>**  Author  :</p>
<p>**  MODIFICATION  HISTORY :<br />
**  The history  of changes should be in chronological sequence</p>
<p>Date       Name of the Proc/ Func       Author        Reasons for Change</p>
<p>[Comments by Version control system will be included in this block].<br />
[The position of the same depends on the version control software and projects].<br />
*/</p>
<p><strong>Some general rules to be followed for functions / procedures.</strong></p>
<ul>
<li>The calling procedure/function should always have to check the   return status and proceed with further processing.</li>
<li>For example, the following statement should not be used</li>
</ul>
<p>Insert into table_one select * from table_two;</p>
<p>The<strong> select *</strong> statement should not be used because, the statement would be invalid in case the structure of the table changes. So the columns have to be explicitly mentioned.</p>
<p><strong>1.1</strong> <strong>Indenting</strong></p>
<p>Tabbing is used for indenting. Statement blocks used with the following statements are indented one tab stop from the corresponding statements.</p>
<ul>
<li> Loops and</li>
<li> Conditional Statements.</li>
</ul>
<p><strong>1.2  Spacing</strong></p>
<p>A single space should be placed before and after all operators.  A single space should also be placed after the comma of each argument in function parameter lists.</p>
<p><strong>1.3  Comments</strong></p>
<ul>
<li>Comments should be placed at the beginning of scripts. Comments at the beginning of functions/procedures should describe the valid values for parameters and what the possible return codes are.</li>
<li> Global and Local variable declarations should also contain comments that identify their usage.</li>
<li> Comments should be placed at the place of modification. In case of a change request, change request number also has to be placed.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://sybaseguru.freetimelabs.com/2009/05/sybase-naming-convention-standard/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sybase Standard for Stored Procedures and Triggers</title>
		<link>http://sybaseguru.freetimelabs.com/2009/05/sybase-standard-for-stored-procedures/</link>
		<comments>http://sybaseguru.freetimelabs.com/2009/05/sybase-standard-for-stored-procedures/#comments</comments>
		<pubDate>Thu, 14 May 2009 09:24:11 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Sybase]]></category>

		<guid isPermaLink="false">http://sybaseguru.freetimelabs.com/?p=63</guid>
		<description><![CDATA[ Rule for Stored Procedures


Procedures should be named PROC_&#60;procedure_name&#62;

Rule for Triggers


Triggers must be named TR&#60;type&#62;_&#60;table name&#62;_&#60;seq&#62; where &#60;type&#62; is ‘I’, ‘U’ or ‘D’ and &#60;table_name&#62; is truncated to 24 characters. (‘I’ represents Insert; ‘U’ represents Update; and ‘D’ represents a delete).




]]></description>
			<content:encoded><![CDATA[<p><strong> Rule for Stored Procedures<br />
</strong></p>
<ol>
<li>Procedures should be named <strong>PROC_&lt;procedure_name&gt;</strong></li>
</ol>
<p><strong>Rule for Triggers</strong></p>
<ol>
<li>
<address>Triggers must be named <strong>TR&lt;type&gt;_&lt;table name&gt;_&lt;seq&gt;</strong> where <strong>&lt;type&gt;</strong> is ‘I’, ‘U’ or ‘D’ and <strong>&lt;table_name&gt;</strong> is truncated to 24 characters. (‘I’ represents Insert; ‘U’ represents Update; and ‘D’ represents a delete).</address>
</li>
</ol>
<p><strong><br />
</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://sybaseguru.freetimelabs.com/2009/05/sybase-standard-for-stored-procedures/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sybase Identity Columns Creation Standard</title>
		<link>http://sybaseguru.freetimelabs.com/2009/05/sybase-identity-columns-creation-standard/</link>
		<comments>http://sybaseguru.freetimelabs.com/2009/05/sybase-identity-columns-creation-standard/#comments</comments>
		<pubDate>Thu, 14 May 2009 09:13:47 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Sybase]]></category>

		<guid isPermaLink="false">http://sybaseguru.freetimelabs.com/?p=59</guid>
		<description><![CDATA[ Rule

 Identity columns should be used for all generated numbers where a gap in the sequence is not significant. i.e surrogate primary keys.
If control of a sequence needs to be retained then this should be implemented using a row in a specific table which holds the next available number in the sequence, this should [...]]]></description>
			<content:encoded><![CDATA[<p><strong> Rule</strong></p>
<ol>
<li><strong> </strong>Identity columns should be used for all generated numbers where a gap in the sequence is not significant. i.e surrogate primary keys.</li>
<li>If control of a sequence needs to be retained then this should be implemented using a row in a specific table which holds the next available number in the sequence, this should be locked, used and then updated.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://sybaseguru.freetimelabs.com/2009/05/sybase-identity-columns-creation-standard/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sybase Standard For Index and Guideline</title>
		<link>http://sybaseguru.freetimelabs.com/2009/05/sybase-standard-for-index-and-guideline/</link>
		<comments>http://sybaseguru.freetimelabs.com/2009/05/sybase-standard-for-index-and-guideline/#comments</comments>
		<pubDate>Wed, 13 May 2009 07:15:51 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Sybase]]></category>

		<guid isPermaLink="false">http://sybaseguru.freetimelabs.com/?p=53</guid>
		<description><![CDATA[Rule

Primary and Unique Key constraints are automatically indexed by the database when the constraint is enabled and cannot be indexed separately.
Foreign Key columns should only be indexed where they improve performance.
Additional non-unique indexes must only be created for specific performance reasons on the basis of demonstrated need.
 Redundant Indexes must be removed.
Two indexes must not [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Rule</strong></p>
<ol>
<li>Primary and Unique Key constraints are automatically indexed by the database when the constraint is enabled and cannot be indexed separately.</li>
<li>Foreign Key columns should only be indexed where they improve performance.</li>
<li>Additional non-unique indexes must only be created for specific performance reasons on the basis of demonstrated need.</li>
<li> Redundant Indexes must be removed.</li>
<li>Two indexes must not share the same leading edge, i.e. The same column(s) as the first part(s) of the index.</li>
<li>Indexes must be named <strong>&lt;table name&gt;_&lt;index type&gt;&lt;seq&gt;</strong> where <strong>&lt;index type&gt;</strong> is: <strong>‘PK</strong>’, <strong>‘AK’</strong>, <strong>‘FK’</strong> or <strong>‘IK’</strong> and <strong>&lt;table name&gt;</strong> is truncated to 25 characters.  <strong>Note:</strong> <strong>‘PK’</strong> refers to a Primary Key index,  <strong>‘FK’</strong> refers to a Foreign Key index, <strong>‘AK’</strong> refers to an Alternate Key index,  <strong>‘IK’</strong> refers to a non-unique index.</li>
<li>Indexed columns must be specified in order of decreasing selectivity, i.e. the first column in the index should have the highest number of distinct values.<strong> Note:</strong> This is to enhance performance.</li>
<li>Columns with only a few distinct values relative to the total number of records must not be indexed. Bitmap Indexes should be used only when there is little or no update activity and tables have low cardinality.  <strong>Note:</strong> A serial scan through the table is faster.</li>
</ol>
<p><strong>Guidelines</strong></p>
<ol>
<li> A further consideration to the ordering of columns in indexes is that it may be possible to cover a number of  indexing requirements through only one index.</li>
<li> The indexing of frequently updated columns should be carefully considered as the cost of maintaining the index may outweigh the benefits of the index.  <strong>Note:</strong> If a column is frequently updated then having an index on it will impact performance because the index will also need to be maintained and this may not be acceptable.</li>
</ol>
<p><strong><br />
</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://sybaseguru.freetimelabs.com/2009/05/sybase-standard-for-index-and-guideline/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
