검색결과 리스트
sqlite에 해당되는 글 2건
- 2012.10.11 Android SQLite Alter Table
글
DB업데이트 시 이전 DB에 대한 처리를 어떻게 할지 고민이었는데 아래의 글을 참고하여 처리하면 될 듯 하다.
When upgrading SQLite database sometimes you need to change the tables scheme. The problem is that SQLite Alter Table SQL formatdoes not support all the options you might need (specifically - dropping columns, changing column types, renaming columns).
One way around this issue is to create a new table & copy the data to the new table. There are few options here, but the best way (I think) is as follows:
1. Create new table in the new format.
2. Copy the data.
3. Drop the original table
4. Rename the new table
For example:
BEGIN TRANSACTION;
CREATE TABLE t_new(a,b);
INSERT INTO t_new SELECT a,b FROM t;
DROP TABLE t;
ALTER TABLE t_new RENAME TO t;
COMMIT;
IMPORTANT: As far as I know 'execSQL' of 'SQLiteDatabase' will NOT run multiple commands. You should run each SQL command in a separate 'execSQL' call (the transaction can be handled from the SQLiteDatabase, not need for explicit SQL commands).
출처 : http://sagistech.blogspot.kr/2011/01/android-sqlite-alter-table.html
'-- Android' 카테고리의 다른 글
export aborted because fatal lint errors (0) | 2014.08.13 |
---|---|
iPhone Tab in Android (0) | 2012.10.12 |
Android push notification implementation using ASP.NET and C# (0) | 2012.10.10 |
AndroidManifest에 지정한 버전 가져오기 (0) | 2012.10.10 |
TextView에 text를 링크(hyperlink)로 지정하기 (0) | 2012.10.10 |
RECENT COMMENT