Sybase Database

Sybase-database

Sybase Database: Database stores the objects, such as Tables, Stored procedures, Views, Indexes, Triggers, Rules, Constraints and Defaults. When we install Adaptive Server Enterprise(ASE), it contains following system databases:
master
model
tempdb
sybsytempdb
systemsysprocs

Syntax to create a database:

CREATE database database_name
[on {default | database_device} [= size]
[, database_device [= size]]…]
Transact-SQL User’s Guide 225
[log on database_device [= size]
[, database_device [= size]]…]
[with override]
[for load]

Examples:

1) Simple way to create a database.
CREATE database pinnapa
go

2) Standard way to create a database. In this example, we have to create data device and log device.

disk init
name=”pinnapadata”,
physname=”/opt/sap/data/pinnapadata.dat”,
size=’100M’
go

disk init
name=”pinnapalog”,
physname=”/opt/sap/data/pinnapalogdevice.log”,
size=’100M’
go

create database pinnapa
on pinnapadata=90 log on pinnapalog=20
go

Altering the database: If we want to increase the size of the database, we can increase by using the alter command.

Syntax:

alter database database_name
[on {default | database_device} [= size]
[, database_device [= size]]…]
[log on {default | database_device} [ = size ]
[, database_device [= size]]…]
[with override]
[for load]

Example:

alter database pinnapa
on pinnapadata=5 log on pinnapalog=5
go

To check the database details:

sp_helpdb pinnapa
go

Dropping a database: Using drop command, we can remove the database and its objects entirely from the ASE server.

Syntax: drop database database_name

Examples:

drop database pinnapa
go
drop database pinnapa1, pinnapa2
go


If we want to use existing database, we have to give following syntax.

Syntax: use database_name

Example:

use pinnapa
go

Powered by k2schools