SQLite如何删除、修改、重命名列?
首先声明:如果你想直接alter,放弃吧。以下内容可以忽略了。
sqlite官方说明如下:
SQLite supports a limited subset of ALTER TABLE. The ALTER TABLE command in SQLite allows the user to rename a table or to add a new column to an existing table. It is not possible to rename a column, remove a column, or add or remove constraints from a table.
大概意思是sqlite的alter功能只是alter table的一个子集,只有部分功能,比如重命名表名,新增列到现有表中。
不支持现有列的重命名,删除和修改。
我们只能通过临时表来解决。
BEGIN TRANSACTION;
CREATE TEMPORARY TABLE temp_table(a);
INSERT INTO temp_table SELECT a from 表;
DROP TABLE 表;
CREATE TABLE 表(a);
INSERT INTO 表 SELECT a from temp_table;
DROP TABLE temp_table;
COMMIT;
这样可以解决,但是如果有自增主键的话,那就要小心了。
相关文档:
QT读写Sqlite数据库
//.h
/****************************************************************************
**
** Date : 2010-05-08
** Author : furtherchan
** If you have any questions , please contact me
**
****************************************************************** ......
AutoIt3开发的操作SQlite数据库的源码下载
部分源码
_SQLite_Startup () ;加载 SQLite.dll
If Not FileExists($SQLite_Data_Path) Then
SQLCreate()
EndIf
$GUI_Form = GUICreate($Title, 300, 435, -1, -1)
GUISetBkColor(0xECE9D8) ; will change background color
$GUI_ListBox = GUIC ......
1 TOP
这是一个大家经常问到的问题,例如在SQLSERVER中可以使用如下语句来取得记录集中的前十条记录:
SELECT TOP 10 * from [index] ORDER BY indexid DESC;
但是这条SQL语句在SQLite中是无法执行的,应该改为:
SELECT * from [index] ORDER BY indexid DESC limit 0,10;
其中limit 0,10表示从第0 ......
sqlite时间函数(转)
2007年12月10日 星期一 13:33
转贴原因:最近设计了一个跨数据库的函数,来测试测试sqlite。
SQLite分页显示:Select * from news order by id
desc Limit 10 Offset 10
这篇文章是根据 SQLite 官方 WIKI 里的内容翻译,如果有什么翻译不当的地方希望大家指出,毕竟我的英文水平实在很差。 SQ ......