Solved

Dynamically Growing Sybase Database

Posted on 2013-11-11
3
442 Views
Last Modified: 2013-11-13
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
Comment
Question by:Jay Redd
  • 2
3 Comments
 
LVL 24

Accepted Solution

by:
Joe Woodhouse earned 500 total points
ID: 39641415
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
 

Author Comment

by:Jay Redd
ID: 39642311
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
 
LVL 24

Expert Comment

by:Joe Woodhouse
ID: 39644629
Ooh, you went gourmet and included some of the optional arguments too. Nicely done. :)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Note: This is the second blog post in a series on email clearinghouses (https://www.xmatters.com/alert-management/blog-email-has-failed-us?utm_campaign=70138000000ydLoAAI&utm_source=exex&utm_medium=article&utm_content=blog-post).   Every month t…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
Concerto provides fully managed cloud services and the expertise to provide an easy and reliable route to the cloud. Our best-in-class solutions help you address the toughest IT challenges, find new efficiencies and deliver the best application expe…

930 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now