How to create database in Sybase

Database is collection of objects like tables, indexes, triggers, views, stored procedures, system tables.. etc. BY default master, model, tempdb, sybsystemprocs, syssystempd databases are created when SAP ASE is installed. To create database, we must have device existed. If you devices are not created yet, Create Physical Devices now. It is good practice to cretae data and logs on separate devices. Database owner is the user who creates the database. Database owner can be changed later. Go to this article to change database owner. When we create database, each database information is stored in master..sysdatabases table.

Database Create Syntax:

create [inmemory] [temporary] database database_name
[use database_name as template]
[on {default | database_device} [= size]
[, database_device [= size]]…]
[log on database_device [= size]
[, database_device [= size]]…]
[with {dbid = number, default_location = “pathname”, override}]
| [[,]durability = { no_recovery
| at_shutdown
| full} ]
[ [,] compression = {none | row | page}]
[ [,] lob_compression = {compression_level | off}]
[ [,] inrow_lob_length = value ] }…
[for {load | proxy_update}]

Options:

Option Description
database_name Name of the dataase.
database_device Name of logical device
size Amount to be allocated on the logical device. It can be k,m,g,t
temporary To create temoprary database.
inmemory To create inmemory database. By defaul all the databases are inmemory database.
Durability Recover ability of the database. Options full, no_recovery, at_shutdown
use as template To use model for creating new database

Examples:

create database k2schools
on schools_data1=’200M’
log on schools_log1=’100M’
go

To get the information about a database:

Note: It is not recommended to use create database databa_name for database creation. This creates database with default settings. Also uses master device to create the database.

To Drop Database:

drop database test1
go

Related Posts

You can leave a response, or trackback from your own site.

Leave a Reply

Powered by k2schools