youtube 說明欄內不允許半形的角括號(小於<、大於>)所以命令有大於>、小於<全部用全形的大於>、小於<替代;若您要直接copy 使用,別忘了將全形的大於>、小於<;改成半形的大於>、小於<;不然命令會有誤喔
SQLite是一個RDBMS(relational
database management system,
關聯式資料庫管理系統),
SQLite中的lite意味著在設置,資料庫管理和所需資源方面的輕量級
SQLite 是一個非常可靠的資料庫,它可以處理 TB 級的資料。
SQLite 號稱是部署和使用最廣泛的資料庫引擎。
SQLite具有以下值得注意的功能:
>>無伺服器(Serverless)
>>獨立自成體系Self-Contained
>>零配置Zero-configuration
>>交易性Transactional
££££本單元內容如下:
1.建立data.db 其內的table名稱為 member
資料如下:
name tel email
john 0912345678 john@gmail.com
marry 0987654321 marry@gmail.com
tom 0987098765 tom@gmail.com
wang 0966684281 wang@gmail.com
sqlite> create table member
(name char(8),tel char(10),email char(20));
sqlite> insert into member
values ("john","0912345678","john@gmail.com"),
...>
("marry","0987654321","marry@gmail.com"),
...>
("tom","0987098765","tom@gmail.com"),
...>
("wang","0966684281","wang@gmail.com");
2.新增一sex 欄位及其資料如下
name tel email sex
john 0912345678 john@gmail.com M
marry 0987654321 marry@gmail.com F
tom 0987098765 tom@gmail.com M
wang 0966684281 wang@gmail.com M
sqlite> alter table member
add sex char(1);
sqlite> update member set sex="M" where
name="john";
sqlite> select * from
member;
john|0912345678|john@gmail.com|M
marry|0987654321|marry@gmail.com|
tom|0987098765|tom@gmail.com|
wang|0966684281|wang@gmail.com|
sqlite> update member set sex="F" where
name="marry";
sqlite> update member set sex="M" where
name="tom";
sqlite> update member set sex="M" where
name="wang";
sqlite> select * from
member;
john|0912345678|john@gmail.com|M
marry|0987654321|marry@gmail.com|F
tom|0987098765|tom@gmail.com|M
wang|0966684281|wang@gmail.com|M
3.新增一筆記錄如下
victor 0968765123 victor@gmail.com M
sqlite> insert into member
values
("victor","0968765123","victor@gmail.com","M");
sqlite> select * from
member;
john|0912345678|john@gmail.com|M
marry|0987654321|marry@gmail.com|F
tom|0987098765|tom@gmail.com|M
wang|0966684281|wang@gmail.com|M
victor|0968765123|victor@gmail.com|M
4.john 的電話 改成 0986345678
sqlite> update member set tel="0986345678"
where name="john";
sqlite> select * from
member;
john|0986345678|john@gmail.com|M
marry|0987654321|marry@gmail.com|F
tom|0987098765|tom@gmail.com|M
wang|0966684281|wang@gmail.com|M
victor|0968765123|victor@gmail.com|M
5.新增一id 欄位及其資料如下
sqlite> alter table member
add id char(3);
sqlite> .schema
CREATE TABLE member (name char(8),tel
char(10),email char(20), sex char(1), id char(3));
sqlite> update member set
id="001" where name="john";
sqlite> update member set
id="002" where name="marry";
sqlite> update member set
id="003" where name="tom";
sqlite> update member set
id="004" where name="wang";
sqlite> update member set
id="005" where name="victor";
sqlite> select * from
member;
john|0986345678|john@gmail.com|M|001
marry|0987654321|marry@gmail.com|F|002
tom|0987098765|tom@gmail.com|M|003
wang|0966684281|wang@gmail.com|M|004
victor|0968765123|victor@gmail.com|M|005
6.查詢總筆數
sqlite> select count(*)
from member;
5
7.查詢會員為男性的筆數
sqlite> select count(*)
from member where sex="M";
4
8.查詢編號 003 的會員資料
sqlite> select * from
member where id="003";
tom|0987098765|tom@gmail.com|M|003
9.查詢姓名victor 的電話及email
sqlite> select tel,email
from member where name="victor";
0968765123|victor@gmail.com
10.將data.db備份一份,檔名為data01.db
.clone data01.db
11.取出data01.db
sqlite>.open data01.db
12.刪除member內 編號003的記錄
sqlite> delete from member
where id="003";
sqlite> select * from
member;
john|0986345678|john@gmail.com|M|001
marry|0987654321|marry@gmail.com|F|002
wang|0966684281|wang@gmail.com|M|004
victor|0968765123|victor@gmail.com|M|005
13.刪除member內所有記錄
sqlite> delete from member
;
sqlite> select * from
member;
14.刪除名稱number的table
sqlite> drop table member;
sqlite> .table
相關單元:
01-資料庫DATABASE相關專有名詞介紹-RDBMS、DBMS、database、table、record、field、Primary Key、Foreign key、database
normalization、First normal form(1NF)、2NF
02-SQLITE3簡介
03-sqlite3視窗版安裝概念
03安裝SQLlite學SQL語言(Windows 版)
04 SQL基本命令 以SQLite3為例 create table、 insert table 、 update 、select https://youtu.be/txYFSUdjttA
05 SQL的運算與delete刪除記錄
06-SQL基本命令 -insert一次插入多筆記錄及練習
06-SQL基本命令 -insert一次插入多筆記錄及練習
07-SQL命令-alter
table add增加欄位
https://www.youtube.com/watch?v=t8vRQ9Ccyys
08-SQLite3-mode顯示或切換-資料顯示格式
09-SQL where 條件-and or
not-between and -in-綜合練習
10-SQL命令-文字運算-文字合併||-通配字元% _-where 欄名 like-where 欄名 in
11-SQL函數及應用說明
12-函數實務練習
13-SQL命令- group by 分類 -order by asc desc排序
14-SQL命令- distinct group
by having及sum avg
round函數
https://youtu.be/ItUt6-4_pD0
15-SQL命令- drop table刪除表格 - delete from 差異
16-SQL命令-case- when- then-
else- end(上)
17-SQL命令-case- when- then-
else- end(下)
18-SQL命令-case when then
else end 風速到練習(全)
19-常用SQL命令說明
20-SQLite3其資料庫table內的record 匯出成CSV檔案的兩種方法
21-SQL命令-table合併-inner
join on(內部連結)
22-SQLite總複習(整理)
23-20211112-23中文訂單檔-內部inner join練習
24-SQLite3 導入Script與導出- count(*)與count(欄名)差異 group
concat()函數應用 與多欄位排序
25-練習-建立data.db資料庫內member table及搜尋資料
相關演講:
20211004社群行銷之客戶關係管理
相關活動:
▶▶▶▶▶▶▶▶活動資訊
▶臺灣雲市集 TCloud 計畫 最高可獲政府補助點數 30,000 點 1 點 = 新臺幣 1 元 叡揚雲端方案連結
▶線上講座_找對雲端工具包,打造營運新活水
叡揚資訊 雲端及巨資事業群
賴俊仁 處長
標籤
#database#table#Record#field#primary
key#Foreign Key#First normal form(1NF)#DBMS(DataBase Management System)#RDBMS(Relational DataBase
Management System)#database normalization#關聯式資料庫管理系統#資料庫管理系統#資料庫#表格#記錄#欄位#第一階正規化#第二階正規化#資料庫正規化#主鍵#外鍵#ACCESS#MYSQL#MariaDB#SQLite3
頻道
#SQLite頻道
https://www.youtube.com/playlist?list=PLWkbsqjwqW3gSEIUilE2KFXXu0sTWxh2u
沒有留言:
張貼留言