日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 综合教程 >内容正文

综合教程

SQLite快速入门二表、视图的创建、修改、删除操作

發布時間:2024/1/4 综合教程 20 生活家
生活随笔 收集整理的這篇文章主要介紹了 SQLite快速入门二表、视图的创建、修改、删除操作 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

表、視圖、索引的創建、修改、刪除操作等

一、表的創建

1、創建表

create if not exists table student(StuID integer);

2、 創建帶有缺省值的數據表:

create table if not exists schoolTable(schID integer default 0, schName varchar default 'hz');

3、if not exists 使用

如果已經存在表名、視圖名和索引名,那么本次創建操作將失敗。加上"IF NOT EXISTS"從句,那么本次創建操作將不會有任何影響.

create table if not exists studentTest(StuID integer);

4、primary key

create table if not exists studenttable (stuid integer primary key asc); 創建主鍵

create table if not existsstudenttable2 (stuid integer,stuName varchar, primary key(stuid,stuName)); 創建聯合主鍵

4 unique約束

create table if not existssutTest(stuID integer unique); 創建唯一性約束

5 check約束

create table if not existssutTest2(stuID integer, ID integer, check(stuID > 0 and ID <0));

二、表的修改

1、修改表名

alter table sutTest rename to stutest;

2、向表中添加新列

alter tablestuTest add column stuName varchar;

三、表的刪除

drop table if exists stuTest 如果某個表被刪除了,那么與之相關的索引和觸發器也會被隨之刪除。

四、創建視圖

1、創建簡單視圖

create view if not exists View_Corporate as select * from corporate where corid > 1

2、創建臨時視圖

create temp view tempView_Corporate as select * from corporate where corid > 1

五、刪除視圖

drop view if exists View_Corporate;

六、索引的創建

1、該索引基于corporate表的corID字段。

create index cor_index on corporate(corID);

2、該索引基于corporate表的corID,corname字段,,并且指定每個字段的排序規則

create index cor_index2 on corporate(corID asc, corName desc);

3、創建唯一索引

create unique index cor_index3 on corporate(corID asc, corName desc);

七、刪除索引

drop index if exists cor_index3;

八、重建索引 reindex;

重建索引用于刪除已經存在的索引,同時基于其原有的規則重建該索引。

九、數據分析 analyze;

十、數據清理 vacuum;

作者:Work Hard Work Smart
出處:http://www.cnblogs.com/linlf03/
歡迎任何形式的轉載,未經作者同意,請保留此段聲明!

總結

以上是生活随笔為你收集整理的SQLite快速入门二表、视图的创建、修改、删除操作的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。