我想在sqlite3的执行以下类型的代码:SQLite的:条件DDL语句
drop table x if (select y from z where col1 = "a");
本质上执行DDL命令IF在同一数据库中当前存在的某些值。
任何想法?
我想在sqlite3的执行以下类型的代码:SQLite的:条件DDL语句
drop table x if (select y from z where col1 = "a");
本质上执行DDL命令IF在同一数据库中当前存在的某些值。
任何想法?
正如其他人指出,运行它,这是不可能的,而无需使用外部工具。
我暂时的解决方案是这样的:
PSEUDOCODE:
// create temp table;
// insert conditional DDL statement(s) into temp table along with an execute column
// run condition, and if valid, set temptable's corresponding row to execute 1;
// after condition is over, run all true statements in temp table
一个SQLite shell脚本:
.bail ON
SELECT CASE COUNT(*)
WHEN 0 THEN 1/0 -- will throw
ELSE 1
END
FROM z
WHERE col1 = 'a';
DROP TABLE x;
与sqlite the_database < the_script
SQL不给你来执行这个功能作为一个班轮的方式。 你会得到在一个命令这样做的最接近的是:
这是一个聪明的做法。它会在控制台上看起来像是失败吗? – seh