Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 487
  • Last Modified:

Dynamically Growing Sybase Database

I am building a little installation/packaging script that deploys various database schema items and procedures. Right now, I just use this to make the database:

CREATE DATABASE dbname
GO

However,
when i point my little package at my larger databases, they quickly fill up the allotted space.

I am not clear how to create a database that has space to grow on sybase....is there some sort of parameter CREATE DATABASE parameter that allows it room to grow, or do I have to supply a specific size per database?
0
Jay Redd
Asked:
Jay Redd
  • 2
1 Solution
 
Joe WoodhousePrincipal ConsultantCommented:
Depending on your ASE version, you can indeed set your databases to automatically grow.

When you don't specify a size like you've done here, you get the default size which again depending on your ASE version is either 2MB or 3MB - hardly enough for any serious work.

You also don't have any control over where the database gets placed which may have effects you don't want... by default the "master" device is available for creating and extending ("altering") user/application databases onto, and this for many reasons is poor practice.

Strongly recommend you create your databases with an explicit size, explicitly on one or more devices. I myself am not a fan of auto-growing databases as I think that causes more trouble than it's worth... if there's a run-away process, without auto-grow it eventually fills the database, which is bad, but with auto-grow it eventually fills all your devices and potentially your file system... which I think is worse.

The chapters in the ASE System Admin Guide about devices and databases are pretty clear on how this works. Well worth taking a look at. The full syntax you might benefit from is:

CREATE DATABASE [name]
ON [device_D1] = [size]
[, [device_D2] = [size], ... ]
LOG ON [device_L1] = [size]
[, [device_L2] = [size], ...]
GO

If you specify size as an integer is is interpreted as megabytes. Because there is so much confusion even in the IT industry about how many megabytes are in a gigabyte, I suggest you instead specify size as a string, i.e. "2G" which is unambiguous.

The above syntax also separates data from log in the database. This is important for any serious production database, and I again refer you to the manuals for the details on why. For now I'll say you can't do incremental backups without this.
0
 
Jay ReddAuthor Commented:
Thanks joe,
I ended up doing something like this (for the benefit of those who are looking, i had a hard time figuring out the device part..)

-- Data Device
disk init
name              = 'do02_data',
physname        = 'C:\sybase\data\do02data.dat',
size        = '15G',
directio    = true,
skip_alloc  = true
go

-- Log Device
disk init
name              = 'do02_log',
physname        = 'C:\sybase\data\do02log.dat',
size        = '7G',
directio    = true,
skip_alloc  = true
CREATE DATABASE do02 on do02_data = '15G' LOG ON  do02_log = '7G'             -- will take some time
GO
sp_dboption do02, 'select into/bulkcopy', true
GO


The  'select into/bulkcopy' was also needed if you're going to use BCP right afterwards.

I just put instructions in my package for the end user to modify these values as needed.
0
 
Joe WoodhousePrincipal ConsultantCommented:
Ooh, you went gourmet and included some of the optional arguments too. Nicely done. :)
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now