python七之資料庫

2021-08-08 00:00:30 字數 947 閱讀 9622

資料庫的命令:

檢視所有的資料庫:show  databases:

檢視當前使用的資料庫:select database():

切換資料庫:use 資料庫名:

建立資料庫:create database   資料庫名  charset = utf8:

刪除資料庫:drop database 資料庫名:

資料表的命令:

檢視所有表:show tables:

建立表:create table 表名(id int auto_increment primary key not null、、、)

刪除表:drop table 表名:

//(一般不要使用刪除語句,或者選用邏輯刪除,選中表,建立乙個新字段,命名為isdelete,使其有0和1兩個值,我們想把某個值刪除時可以使其isdelete值為1,然後利用資料庫表的篩選功能,只讓其顯示出isdelete==0的資料,這樣顯示出來的直接就是為未刪除的資訊,這樣邏輯上的刪除就防止重要資料資料的丟失)

修改表:alter table 表名  add|change|drop  列

資料的命令:

查詢:select  *from 表名  (後可加條件:where name like '...' or name like '...':):

增加:insert  into 表名 values(...):

修改:update 表名 set 字段=值...

刪除:delete  from 表名

範圍查詢:select *from students where id in( , , ):   //使用in!!!

查詢乙個連續的範圍:select  *from students where id between 3 and 8:  // between...and...

空判斷:null不占用記憶體,『  』空字串也為空,但是有占用記憶體

Python庫之資料庫連線

資料庫連線可用於連線眾多資料庫以及訪問通用資料庫介面,可用於資料庫維護 管理和增 刪 改 查等日常操作。1.mysql connector python 型別 第三方庫 描述 mysql官方驅動連線程式 推薦度 13.bsddb3 型別 第三方庫 描述 berkeley db連線庫 15.dbhas...

資料庫(七)資料庫分頁處理

資料分頁處理的方式有 1 客戶端 應用程式或瀏覽器 分頁 2 應用伺服器分頁 list list executequery select from employee order by id int count list.size list sublist list.sublist 10,20 優點 ...

資料庫原理(七) 資料庫設計

一 資料庫設計 特點 1 資料庫設計 幹件 技術與管理的介面 軟體 硬體 2 資料庫設計 結構 資料設計 行為 處理設計 二 資料庫設計階段 1 需求分析階段 產物是資料字典。2 概要設計階段 產物是er圖。3 邏輯設計階段 產物是資料庫模型圖。4 物理設計階段 5 實施階段 產物是資料庫 6 執行...