<kbd id="afajh"><form id="afajh"></form></kbd>
<strong id="afajh"><dl id="afajh"></dl></strong>
    <del id="afajh"><form id="afajh"></form></del>
        1. <th id="afajh"><progress id="afajh"></progress></th>
          <b id="afajh"><abbr id="afajh"></abbr></b>
          <th id="afajh"><progress id="afajh"></progress></th>

          了解如何輕輕松松對(duì)數(shù)據(jù)進(jìn)行處理

          共 2980字,需瀏覽 6分鐘

           ·

          2021-03-14 17:11


          關(guān)注我們“Python日志”


          哈嘍各位下午好

          本期土豆不說python

          來跟大家說一說數(shù)據(jù)庫


          數(shù)據(jù)庫是一種存儲(chǔ)結(jié)構(gòu),它允許使用個(gè)各種格式輸入、處理和檢索數(shù)據(jù),不必在每次需要數(shù)據(jù)時(shí)重新輸入。






          特點(diǎn)



          實(shí)現(xiàn)數(shù)據(jù)共享

          減少數(shù)據(jù)的冗余

          數(shù)據(jù)的獨(dú)立性

          數(shù)據(jù)實(shí)現(xiàn)集中控制

          數(shù)據(jù)的一致性和可維護(hù)性


          層次


          物理數(shù)據(jù)層:數(shù)據(jù)庫最內(nèi)層,是物理存儲(chǔ)設(shè)備上實(shí)際存儲(chǔ)的數(shù)據(jù)集合

          概念數(shù)據(jù)層:中間一層,是存儲(chǔ)記錄的集合

          邏輯數(shù)據(jù)層:是用戶所看到的和使用數(shù)據(jù)庫,是一個(gè)或者一些特定用戶使用的數(shù)據(jù)集合,即邏輯記錄的集合


          數(shù)據(jù)庫的種類及其功能


          數(shù)據(jù)庫按照數(shù)據(jù)結(jié)構(gòu)來組織、存儲(chǔ)和管理數(shù)據(jù),實(shí)際上,數(shù)據(jù)庫一共有三種模型:

          1.層次模型就是以“上下級(jí)”的層次關(guān)系來組織數(shù)據(jù)的一種方式,層次模型的數(shù)據(jù)結(jié)構(gòu)看起來就像一顆樹

          2.網(wǎng)狀模型把每個(gè)數(shù)據(jù)節(jié)點(diǎn)和其他很多節(jié)點(diǎn)都連接起來,它的數(shù)據(jù)結(jié)構(gòu)看起來就像很多城市之間的路網(wǎng)

          3.關(guān)系模型把數(shù)據(jù)看作是一個(gè)二維表格,任何數(shù)據(jù)都可以通過行號(hào)+列號(hào)來唯一確定,它的數(shù)據(jù)模型看起來就是一個(gè)Excel表


          SQL語言


          SQL結(jié)構(gòu)化查詢語言,使用SQL可以方便的查詢、操作、定義、和控制數(shù)據(jù)庫中的數(shù)據(jù)。

          組成部分:數(shù)據(jù)定義語言、數(shù)據(jù)操縱語言、數(shù)據(jù)控制語言、事務(wù)控制語言



          隨著應(yīng)用程序的功能越來越復(fù)雜,數(shù)據(jù)量越來越大,如何管理這些數(shù)據(jù)就成了大問題:

          1.讀寫文件并解析出數(shù)據(jù)需要大量重復(fù)代碼;

          2.從成千上萬的數(shù)據(jù)中快速查詢出指定數(shù)據(jù)需要復(fù)雜的邏輯。



          對(duì)于一個(gè)關(guān)系表,除了定義每一列的名稱外,還需要定義每一列的數(shù)據(jù)類型。

          關(guān)系數(shù)據(jù)庫支持的標(biāo)準(zhǔn)數(shù)據(jù)類型包括數(shù)值、字符串、時(shí)間等:



          目前,主流的關(guān)系數(shù)據(jù)庫主要分為以下幾類:

          商用數(shù)據(jù)庫,例如:Oracle,SQL Server,DB2等;

          開源數(shù)據(jù)庫,例如:MySQL,PostgreSQL等;

          桌面數(shù)據(jù)庫,以微軟Access為代表,適合桌面應(yīng)用程序使用;

          嵌入式數(shù)據(jù)庫,以Sqlite為代表,適合手機(jī)應(yīng)用和桌面程序。


          什么是SQL?


          SQL是結(jié)構(gòu)化查詢語言的縮寫,用來訪問和操作數(shù)據(jù)庫系統(tǒng)。SQL語句既可以查詢數(shù)據(jù)庫中的數(shù)據(jù),也可以添加、更新和刪除數(shù)據(jù)庫中的數(shù)據(jù),還可以對(duì)數(shù)據(jù)庫進(jìn)行管理和維護(hù)操作。



          Mysql常用語句


          Mysql最常用的命令


          1、顯示數(shù)據(jù)庫列表:show databases;
          2、顯示庫中的數(shù)據(jù)表:show tables;
          3、顯示數(shù)據(jù)表的結(jié)構(gòu):describe 表名;
          4、建庫:create database 庫名;
          5、建表:create table 表名 (字段設(shè)定列表);
          6、刪庫和刪表:drop database 庫名;drop table 表名;
          7、將表中記錄清空:delete from 表名;(內(nèi)容清空,自增id不會(huì)被清掉,自增id會(huì)保留)mysql> truncate table users;數(shù)據(jù)庫返回:“Query OK, 0 rows affected (0.04 sec)”(成功返回0)(自增id也一同會(huì)被清掉)
          8、顯示表中的記錄:select * from 表名


          庫的基本操作


          1.創(chuàng)建數(shù)據(jù)庫:mysql> create database ceshi;
          2.連接數(shù)據(jù)庫mysql> use ceshi;
          3.查看當(dāng)前使用的數(shù)據(jù)庫mysql> select database();
          4.當(dāng)前數(shù)據(jù)庫包含的表信息mysql> show tables;
          5.刪除數(shù)據(jù)庫mysql> drop database ceshi;


          表的基本操作


          一、建表1.命令:create table <表名> (<字段名 1> <類型 1> [,..<字段名 n> <類型 n>]);
          1.1例子:mysql> create table Class(id int(4) not null(不能為空) primary key(主鍵) auto_increment(自增長(zhǎng)), name varchar(25) not null, age int (4) not null default'0'); (default'0' 設(shè)置默認(rèn)值為0
          二、獲取表結(jié)構(gòu)2命令: desc 表名,或者show columns from 表名
          2.1例子:mysql> desc Class;mysql> describe Class;mysql> show columns from Class;
          三、插入數(shù)據(jù)3.命令:insert into <表名> [( <字段名 1>[,..<字段名 n > ])] values ( 值 1 )[, ( 值 n )]
          3.1例子:mysql> insert into Class values(1,'Wrry',26),(2,'ZJW',28);
          四、查詢表中的數(shù)據(jù)
          4.查詢所有行
          mysql> select * from Class;
          4.1查詢前幾行數(shù)據(jù)
          4.1.1例如:查看表 Class 中前 3 行數(shù)據(jù)mysql> select * from Class limit 0,3;
          4.1.2或者mysql> select * from Class order by id limit 0,3; (order by id :以id排序)
          五、刪除表中數(shù)據(jù)
          5.1命令:delete from 表名 where 表達(dá)式
          5.2例如:刪除表 Class 中編號(hào)為 6 的記錄mysql> delete from MyClass where id=1;
          六、修改表中數(shù)據(jù)
          6.命令:update 表名 set 字段=新值,... where 條件6.1例如:mysql> update Class set name='AI' where id=1;
          七、在表中增加字段
          7命令:alter table 表名 add 字段 類型 其他;
          7.1例如:在表 Class 中添加了一個(gè)字段 sex,類型為 varchar(25),默認(rèn)值為 0mysql> alter table Class add sex varchar(25) default '0'
          八、更改表名
          8.命令:rename table 原表名 to 新表名;
          8.1例如:在表 Class 名字更改為 MClassmysql> rename table Class to MClass;
          九、刪除表
          9.命令:drop table <表名>
          9.1例如:刪除表名為 MClass 的表
          mysql> drop table MClass;

          ?

          好啦,數(shù)據(jù)庫的基礎(chǔ)大概就是這樣啦

          我們下期再見哦

          覺得不錯(cuò)的話可以給土豆一個(gè)一鍵三連哦



          關(guān)
          Python日志
          一個(gè)正經(jīng)搞知識(shí)的公眾號(hào)

           內(nèi)容源自網(wǎng)絡(luò)

          瀏覽 66
          點(diǎn)贊
          評(píng)論
          收藏
          分享

          手機(jī)掃一掃分享

          分享
          舉報(bào)
          評(píng)論
          圖片
          表情
          推薦
          點(diǎn)贊
          評(píng)論
          收藏
          分享

          手機(jī)掃一掃分享

          分享
          舉報(bào)
          <kbd id="afajh"><form id="afajh"></form></kbd>
          <strong id="afajh"><dl id="afajh"></dl></strong>
            <del id="afajh"><form id="afajh"></form></del>
                1. <th id="afajh"><progress id="afajh"></progress></th>
                  <b id="afajh"><abbr id="afajh"></abbr></b>
                  <th id="afajh"><progress id="afajh"></progress></th>
                  无码国产精品96久久久久孕妇 | 波多野结衣一区二区三区在线观看 | 亚洲家庭乱轮五月天 | 久久伊人青青草 | 国产色婷婷AV |