简体   繁体   English

在SQL表创建过程中包含文件

[英]Include file during SQL table creation

I have two files: Table creation and Table insert 我有两个文件:表创建和表插入

One creates a table with rows, and the other inserts data into those rows 一个创建带有行的表,另一个则将数据插入到这些行中

Rather than editing the rows name/type in each file, I tried including rows.php but I get an error 我没有编辑每个文件中的行名/类型,而是尝试包含rows.php,但出现错误

rows.php looks like this: rows.php看起来像这样:

Row1 CHAR(15),
Row2 CHAR(15),
Row3 CHAR(15),

**tablecreation.php looks like this:**
$sql = "CREATE TABLE TableTest 
(
<?php include 'rows.php'; ?>
)";

**tableinsert.php looks lkike this:**
$sql = "INSERT INTO TableTest 
(
<?php include 'rows.php'; ?>
)";

The syntax for create table and for insert with a column list are different. create tableinsert带有列列表的语法是不同的。

The create table statement has data types. create table语句具有数据类型。 The insert statement does not. insert语句没有。

So, the following generates an error: 因此,以下生成错误:

insert into TableTest(Row1 char(15), . . .)

Because the data type is not allowed in that context. 因为在该上下文中不允许使用数据类型。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM