creating a database
Posted in 2000
Topics: Server Administration
Hi,
which tool do I have to use to create a database from a file
(not interactively like with dbaccess)?
bye,
Klaus
how about...
dbaccess sysmaster<<!!
create database foo;!!
or echo "create database foo"|dbaccess sysmaster
hth,
bk
In article <n21j2t8gokdj97qqnu843vh8ao8g57vvue@4ax.com>,
Thomas Schmidt <schmidt@kdnet.de> wrote:
> Hi,
>
> which tool do I have to use to create a database from a file
> (not interactively like with dbaccess)?
>
> bye,
> Klaus
>
Sent via Deja.com http://www.deja.com/
Before you buy.
Thomas Schmidt wrote:
> which tool do I have to use to create a database from a file
> (not interactively like with dbaccess)?
As various people pointed out, the default tool to use is DB-Access.
The alternative is probably SQLCMD from the IIUG Software Archive.
What no-one said correctly is how to create a database with DB-Access
from a command file. The answers all gave a database name, in one case
sysmaster, followed by the file name. Using sysmaster will be OK as
long as you're using IDS. If you're using SE, it won't work -- there is
no sysmaster database for SE.
What will work, for all (Unix) systems is:
dbaccess - file
This will run in batch mode (not interactively). The dash means "do not
pre-select any database"; the "file" means read the commands from
"file.sql". That file would include the 'create database whatever with
buffered log' command, or something similar.
Note that SQLCMD would allow you to specify:
sqlcmd -e 'create database whatever with buffered log'
and even allows you to omit the -e option if you're as lazy as I usually
am.
--
Yours,
Jonathan Leffler (Jonathan.Leffler@Informix.com) #include <disclaimer.h>
Guardian of DBD::Informix v1.00.PC1 -- http://www.perl.com/CPAN
"I don't suffer from insanity; I enjoy every minute of it!"
Use the isql product of Informix.
If your file which contains the sql script is createdb.sql (note that
the extension .sql is required), then you issue the following command:
isql -sq <DATABASE> <SQL FILE>
Where DATABASE is any existing database in your engine instance, and SQL
FILE is the file that contains the SQL scripts.
Thomas Schmidt wrote:
> Hi,
>
> which tool do I have to use to create a database from a file
> (not interactively like with dbaccess)?
>
> bye,
> Klaus
Gerard Lapidario wrote:
> Use the isql product of Informix.
>
> If your file which contains the sql script is createdb.sql (note that
> the extension .sql is required), then you issue the following command:
>
> isql -sq <DATABASE> <SQL FILE>
>
> Where DATABASE is any existing database in your engine instance, and SQL
> FILE is the file that contains the SQL scripts.
>
> Thomas Schmidt wrote:
> > which tool do I have to use to create a database from a file
> > (not interactively like with dbaccess)?
Hmm, ISQL certainly works, but so does DB-Access:
dbaccess - schema.sql
isql - schema.sql
Or you can get SQLCMD from the IIUG Software Archive.
sqlcmd schema.sql
The solo dash indicates "do not preselect a database"; you could replace
it with the database name if the database has already been created but
you need to create the tables etc in the database (and the SQLCMD
command line becomes "sqlcmd -d dbase -f schema.sql", though the -f
could also be omitted -- it uses a simple heuristic to decide whether
stray arguments are SQL commands (they have spaces in them) or a file
name (they don't)).
--
Yours,
Jonathan Leffler (Jonathan.Leffler@Informix.com) #include <disclaimer.h>
Guardian of DBD::Informix v1.00.PC1 -- http://www.perl.com/CPAN
"I don't suffer from insanity; I enjoy every minute of it!"