如何使用PHP / PDO从另一个现有SQLite数据库导入数据库的一个表来创建SQLite数据库?
这是我到目前为止在伪代码中的想法:
$existing_database = 'database1.sqlite';
try
{
$dbhandle = new PDO('sqlite:database2.sqlite');
$dbhandle->exec("CREATE TABLE new_table IMPORT table from $existing_database");
$dbhandle = NULL;
}
catch(PDOException $e)
{
print 'Exception : '.$e->getMessage();
}
答案 0 :(得分:0)
existing_database ='database1.sqlite';
try
{
$dbhandle = new PDO('sqlite:database2.sqlite');
$dbhandle->exec("ATTACH DATABASE 'database1.sqlite' AS existing_database");
$dbhandle->exec('CREATE TABLE table AS SELECT * FROM existing_database.table');
$dbhandle = NULL;
}
catch(PDOException $e)
{
print 'Exception : '.$e->getMessage();
}