SQLite中是否有SQL命令(对于C#.NET)执行与此相同的操作?
DELETE * FROM * WHERE id='idnumber'
答案 0 :(得分:2)
不,没有。
一种方法是将一个小脚本写入query metadata tables到创建另一个脚本,其中包含一系列单独的delete
语句,每个表一个。
一个例子可能是(假设每个表都有一个ID列):
select 'delete from ' || name || ' where ID = 42'
from sqlite_master
where type = 'table'
这将为每个表生成一个delete
语句,然后您可以捕获并作为脚本运行。
但数据库开发人员通常知道他们的表名称是一个好主意: - )
答案 1 :(得分:0)
此删除操作将擦除数据库中的所有内容:
.output wipe.sql
.print BEGIN TRANSACTION;
SELECT 'DELETE FROM ' || name || ' WHERE id="idnumber";'
FROM sqlite_master
WHERE type = 'table';
.print COMMIT;
.print VACUUM;
.output
-- .read wipe.sql
请注意,如果您遗漏了WHERE id="idnumber"
,将会清除数据库!
答案 2 :(得分:-1)
您可以尝试使用它:
//You can do it with the following DANGEROUS commands:
PRAGMA writable_schema = 1;
delete from sqlite_master where type = 'table';
PRAGMA writable_schema = 0;
//you then want to recover the deleted space with
VACUUM
//and a good test to make sure everything is ok
PRAGMA INTEGRITY_CHECK;
希望它对你有用。