List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:August 7 2002 2:52pm
Subject:Re: Can I have include-files within CREATE TABLE ?
View as plain text  
SOURCE and \. are separate commands, not commands that can be part of
other statements.  There is no way to do what you want using just the
mysql client.

However...
That doesn't mean you couldn't preprocess your files with some other
program like m4 to produce the SQL source you want, and then run the
result into mysql.

>I'd like to have certain fields identically in every table of my scheme.
>It'd be helpful if I could define them in a seperate file and get 
>them included when I run the table creation SQLs throug mysql.
>
>It'd be like a strip down version of "heritation".
>But the folowing syntax won't work.
>Is there a way to do it another way ?
>
>
>---- object.inc ----
>   rowid INTEGER UNSIGNED NOT NULL UNIQUE AUTO_INCREMENT,
>-- ------------------------------------------------------------------
>   last_change_date TIMESTAMP NOT NULL,
>   last_change_pid_fk INTEGER UNSIGNED NOT NULL,
>   INDEX ind_last_change_fk (last_change_pid_fk),
>   FOREIGN KEY (last_change_pid_fk) REFERENCES tbl_persons(person_id),
>-- ------------------------------------------------------------------
>   created_date DATETIME	NOT NULL,
>   created_pid_fk INTEGER UNSIGNED NOT NULL,
>   INDEX ind_created_pid_fk (created_pid_fk),
>   FOREIGN KEY (created_pid_fk) REFERENCES tbl_persons(person_id),
>------------------
>
>
>--- mytable.sql ---
>CREATE TABLE myTable (
>\. object.inc
>
>   mytable_id INTEGER .... yada yada yada ...
>);
>-------------------
Thread
Can I have include-files within CREATE TABLE ?Andreas7 Aug
  • Re: Can I have include-files within CREATE TABLE ?Paul DuBois7 Aug