-noexec-get-rebuildTo get an overview of the process where DBBUILD fits in, see the page Life-cycle of a database.
Contents:
Command-Line Syntax
Current Directory when Building
How DBBUILD Builds the Database
Loading BCP Files
Output from DBBUILD
Help Tables
dbbuild {-database db [-Server server] [-User user] [-Password pwd] [-save file]}
| -noexec
[-config config-file | -VSS SS-path] [-subsystem subsys]
[-label version] [-get | -use_disk]
[-rebuild] [-log file] [-bcp [directory]] [-[no]insert] [-force]
[-sptwice] [-tablesfirst]
[-charset CP] [-[no]crypt] [-environment DEV | TEST | PROD]
[-Macro ¯o=value [...]] -site site-id] [-[no]subscriber]
[-undef ¯o [...]]
Thus, you must specify either of -database-noexec
| Database switches | |
|---|---|
|
Name of the database to build. Prior to invoking DBBUILD, you must have created the database with CREATE DATABASE. The database may be completely empty, save objects created by SQL Server, or it may contain one or more subsystems since previous builds. |
|
The server where the database resides. If you do not specify -ServerNote that if you specify the server instance by port number, you must enclose the server specifcation in quotes, for instance -S
"127.0.0.1,2093". |
|
Which login and password to use with SQL authentication. If you leave out
both username and password, AbaPerls will use Windows authentication. If you
specify -passwordNo matter if you use SQL authentication or Windows authentication, the login you use must map to a database user with dbo as the default schema, or AbaPerls will not let you proceed. Obviously, the user needs permission to perform all actions implied by AbaPerls and the files you load. |
|
Use this option to save the generated SQL code to file in case you wish to
review it. If you do not provide a file extension,
DBBUILD adds .SQL. By default DBBUILD does not save any file. Do not use the saved SQL code to build another database, but always build your databases directly with DBBUILD. Two executions of DBBUILD typically generates different SQL code depending configuration options, whether other subsystems are present in the database, the version of SQL Server etc. |
|
Specifies that DBBUILD is to get the files and run them through
Preppis to
get all required include files and compile C# and VB files, but not proceed with further steps in the
AbaPerls file-loading process. You typically use -noexec-getWhen you specify , you cannot
specify , ,
or
.
|
| SourceSafe options | |
|
Instructs DBBUILD to build the database from the
config-file you have specified. DBBUILD tacks on
/SQL on the project specifications in the config-file and emits a warning for
the projects in the config-file that do not have any SQL project. If there is no subsystem in the database, DBBUILD will use the configuration options in the config-file both on database level and on subsystem level. If there already is a subsystem in the database, DBBUILD will obey the options saved in the database for the database level, and ignore the database-level options in the config-file. DBBUILD will apply the configuration options in the config-file for the subsystem(s) that it adds. If the config-file includes a subsystem which is already present in the database, DBBUILD skips this subsystem, unless you specify .
|
|
An SS-path for a
singular SourceSafe project to build from. When you specify -VSS-subsystem-subsystem-VSS |
|
-subsystem,
DBBUILD will only build the specified subsystem.Together with ,
specifies the name of the subsystem you build. If you
specify -VSS without,
DBBUILD will name the subsystem NAMELESS. You can only use this name in a
database where there are no other subsystems.
|
|
Which version in SourceSafe that DBBUILD is to read from. For a
config-file, this is a version, specified by
version number, date or label, of the config-file, which in its turn
determines which version of the projects to use, as described on the
config-file page. For a singular project that you specify with ,
is a version number, date
or label of that project. If
the subsystem ABAPERLS is installed in the database, you must specify a
label
on the form LetterMajor.Middle.Minor.
|
|
With , DBBUILD creates, in the current directory, a directory for each
subsystem it builds. In each subsystem directory, DBBUILD gets the files and
places them in an AbaPerls SQL directory structure You typically use together with
to create kits for installation at customer sites.You cannot use together with .
If you specify , you must also specify
-config.
|
|
There are two uses for . When you specify or , you
can use to instruct DBBUILD to apply all steps in the
AbaPerls file-lookup order, and thus let local files
override what is in SourceSafe. With (the
default with or -config), is handy when
you want to test the effects of some changes that you do not want to check in,
for instance removal of one or more columns in a table.When you specify neither of
or , this implies
. You typically use this to build from a disk structure created with
-get |
| Miscellaneous | |
|
Reloads most of the objects in one more existing subsystem in a database. See below
under How DBBUILD Builds the Database for the exact details on which objects that are
reloaded. When you specify , DBBUILD takes
all configuration options from the config-file
and replaces those already present in the database. The options in the database
are discarded. If specify -rebuild-subsystemNote: with , DBBUILD
does not check the config-file against the database, and neither does it check
whether the versions of the subsystem are correct, so you need to be careful when you
use -rebuild |
|
Instructs DBBUILD to load BCP files
from the specified directory. If you specify without any
directory, DBBUILD will read the BCP files
from the current directory. See further below under
Loading BCP files about
the format of the BCP files etc.For the subsystem ABAPERLS, DBBUILD ignores ,
but always loads the INSERT-files for ABAPERLS.You cannot specify -bcp-noexec |
|
Whether DBBUILD should load INSERT-files or not. If you
do not specify , the default depends on the
-bcp, nor
, DBBUILD will load INSERT-files,
and you need to specify if you for some
reason do not want to load INSERT-files. If you specify
but not ,
DBBUILD will not load INSERT-files. Thus, if you
want to load both BCP files and INSERT-files, you
must specify . (The INSERT-files
are loaded after the BCP files, see below.)For the subsystem ABAPERLS, DBBUILD ignores the setting of , and always loads the
INSERT-files for this subsystem.
|
|
Name of log file for the build. If you do not specify
DBBUILD writes the log for the build to db.LOG.
See below about the contents of the log file. |
|
Specifies that if there is a conflict between the
configuration options in the
config-file, or those saved in the
database, and the configuration options on the command-line, the command-line takes
precedence. If you do not specify , and there is
a conflict, DBBUILD will abort with an error message, and
no file will be loaded. Only use when you really need to override the configuration
saved in the database.
|
|
Specifies that DBBUILD should run through the stored
procedures in the SP directory
twice. This is good on SQL 2005 and later, if you want complete dependency
information in the database that you can review with sp_depends. (On earlier
versions of SQL Server, does not help, as
dependency information are erased with ALTER PROCEDURE.) |
-tablesfirst |
Instructs DBBUILD to use a build order, where all table
and view definitions are loaded before any functions or stored procedures. This
is useful if you find that you in practice refers to tables in higher subsystems
in lower subsystems. (Something you probably should avoid.) For the exact
details, see the section How DBBUILD
builds the database below. You cannot specify with . |
| Configuration options | |
|
These switches are configuration options.
The setting of a configuration option is primarily taken from the
config-file or
the database according to the
prededence rules for
configuration options. If the config-file/database defines a setting for an option and you specify a different
setting on the command-line, you must use to override. |
When you build from SourceSafe
and specify -use_disk
You could also have the files in the working directories that mirror the AbaPerls SQL directory structure in SourceSafe. In this case, while you could run DBBUILD from any directory in the structure, I recommend using the top directory or SCRIPTS. If you want to override files from different subsystems, you can create one directory for each subsystem (with the same name as the subsystem), and each such directory have an AbaPerls SQL directory structure where you place the files you want to override.
When you build from disk without using SourceSafe,
your current directory should have on directory for each subsystem, and in each
subsystem directory there should be an SQL directory under which there is an
AbaPerls SQL directory structure. Be careful so
that the path to the current directory does not include any of the directory
names from the AbaPerls SQL directory
structure, because in such case DBBUILD will assume that you
are inside the structure – not above the top of another. If you are toying out
an entirely new database, you may have not defined any subsystems, but you still
need to use -subsystem-subsystem
When you build from SourceSafe without specifying -use_disk
The first thing DBBUILD does, is to check whether there are any tables in the database (not counting the system tables of SQL Server). If DBBUILD finds no tables, DBBUILD removes all types, rules and defaults (created with CREATE DEFAULT) from the database, assuming that these are inherited from the model database. (And assuming that no one in his sane mind puts user tables in model.)
DBBUILD then determines which subsystems to build:
-config-subsystem-VSS-subsystem-config-VSS-subsystemFor each subsystem, DBBUILD determines which files to load in one of these ways:
-config-VSS-use_diskHaving determined the list of files to load, DBBUILD then proceeds to loads the files in this order: (Note that when we say "directory" this could also refer to a project in SourceSafe. And recall that all subdirectories are included.)
-sptwice , DBBUILD loads the files in
SP once
more.-bcp , DBBUILD loads
BCP files as
detailed under loading BCP files, below. (Not for
ABAPERLS).
-insert (which is the default
unless you specified -bcp ) or the subsystem is ABAPERLS,
DBBUILD loads TBL/*.INS.
Within each group, the load order follows the sort order defined by the Windows regional settings on system level. (That is, if you as a user have Swedish regional settings, but the default setting on the machine is US-English, then DBBUILD will sort according to US-English. It's Perl that works this way, and AbaPerls can't but comply.) There are however a few deviations:
With the switch you can rebuild a database,
without affecting the data in the tables. In this case DBBUILD performs only
steps 1, 3, 4, 9-14 and 16-23 above. That is, types and tables are
not rebuilt,
while synonyms, assemblies, views, functions, procedures, triggers, indexes, INSERT-files, and foreign keys
are reloaded. Note that even if you specify
-bcp-rebuild
When you specify the switch ,
DBBUILD traverses the subsystem in two rounds, and in the first round
DBBUILD performs steps
Note: the build order makes some assumption how things refer to each other that are not always true. The most typical case is user-defined functions that may refer to tables and views, but tables and views may also refer to user-defined functions. With the build order of DBBUILD the creation of a table of a view fails if there is a reference to a user-defined function. A workaround is to include a $REQUIRE directive in the file that defines the table or view to have the function created before the table/view. (While off-topic for this manual, a word of caution for scalar user-defined functions: they almost always turn a query from being truly set-based to be iterative like a cursor. Thus, while you can use a scalar UDF in a constraint, it may have serious performance impacts.)
-bcp , DBBUILD
reads BCP files from the current directory. That is, DBBUILD does not read the
BCP files from the subsystem directories, but assumes that all files are in the
same place. This is advantageous when you want to rebuild a database from
scripts, for instance because you want to change the collation (sort order), or
the database is corrupted. You can bulk out all data into one place, and do not
need to sort the files per subsystem.Note that AbaPerls system tables are never loaded through BCP, but will be repopulated with the objects and subsystems that are included in the build.
The files should be named table.BCP, that is the same name as the table, and with the file extension .BCP. DBBUILD attempts to load non-empty files named *.BCP that fits with the tables in the current subsystem. Empty BCP-files are merely noted in the build log.
DBBUILD determines the format of the BCP files in this way:
@!@ on the first line or the string
<->
on the second line, DBBUILD will assume these command-line switches
for BCP: -c -t@!@ -r"\n<->\n" .
(This is the character format used by DOBCP.)Note that DBBUILD is not able to detect if the BCP file was
generated with the -unicode
Overall the use of format files is recommended. For instance, if you move data from one collation to another and use native format, you need to use format files to describe the BCP files correctly. (Note that sql_variant columns will retain their collation, since for them the collation is part of the data.)
DBBUILD runs BCP with a batch size of 1000, and
uses the switch if required to maintain
IDENTITY values.
DBBUILD runs BCP with the option , meaning that all constraints for the table
are checked when the data is loaded. Typically foreign keys will not be present
when BCP runs, as DBBUILD loads them later.
On the other hand, CHECK constraints are present if they appear
in the .TBL file (which is the normal thing). If DBBUILD
would load the files without the constraint checks, SQL Server would mark the
constraints as "not trusted", and the optimizer would not ignore the constraints
when building query plans, which in some cases can lead to less effecient plans.
There is one exception to this: if there are types with the name ending in _upduser, DBBUILD assumes that for each such type there is a rule bound to it that requires the value to be equal to SYSTEM_USER or similar. DBBUILD unbinds these rules prior to bulk-loading, assuming that then name of the rules is the type name with _rule tacked on to it. When DBBUILD has finished bulk-loading the subsystem, it rebinds the rules. If you use some other mechanish, for instance a constraint to enforce the value of an auditing column, I'm afraid that it's not going to work with DBBUILD.
DBBUILD produces two forms of output: it prints to the command-line window, and it produces a log file.
The output to the command-line window only serves the purpose of giving progress information. There is no need to monitor the output.
On the other hand, it is essential that you check the log file, because if a file produces errors when DBBUILD loads it, the errors are written to the log only. The log file includes a full list of files that DBBUILD has loaded.
First in the log file, you find a header which reports the user that run the script, when he did it and with which command-line options. For each subsystem, there is a header with the configuration options that DBBUILD used for that subsystem. DBBUILD reports only the configuration options that were set explicitly, by command-line switches, or settings read from the database.
For a database with a reasonable number of tables, the log becomes huge and tedious to read directly. To this end there is the command LISTERRS that extracts the interesting messages from the log as well as the header information.
Note: There is one category of messages that are only printed to the command-line window: warnings and errors from Perl itself. Such messages should not occur, and are likely to be indications of bugs in AbaPerls (or Perl). A Perl error is usually fatal and terminates DBBUILD.
Even if you opt to not install the subsystem ABAPERLS in your database, DBBUILD one help tables: abainstallinfo. Older versions of DBBUILD also created ababuildaid in tempdb, but this has been dropped.
Abainstallinfo gives an installation history for the database, akin to the one in abainstallhistory, and is also maintained by the update scripts generated by DBUPDGEN. If you later opt to add the ABAPERLS subsystem to your database, abainstallinfo will be converted to abainstallhistory.
Copyright © 1996-2010,
Erland Sommarskog SQL
All rights reserved. AbaPerls is available under
Perl Artistic License
This page last updated 10-09-02 13:25