課程一期web開發(fā)技術(shù)mysql基礎(chǔ)_第1頁
課程一期web開發(fā)技術(shù)mysql基礎(chǔ)_第2頁
課程一期web開發(fā)技術(shù)mysql基礎(chǔ)_第3頁
課程一期web開發(fā)技術(shù)mysql基礎(chǔ)_第4頁
課程一期web開發(fā)技術(shù)mysql基礎(chǔ)_第5頁
已閱讀5頁,還剩11頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)

文檔簡介

1、MySql基礎(chǔ)MySql簡介MySql 是一款使用非常廣泛的免費的關(guān)系型數(shù)據(jù)庫特點:免費、快速、靈活、高效最新版本:5.5.24典型用戶:維基百科、facebook其他數(shù)據(jù)庫產(chǎn)品:微軟 Ms Sql,Oracle數(shù)據(jù)庫里儲存著大量的信息,需要有一種通用手段對其進行管理數(shù)據(jù)添加刪除查詢修改SQL是用于數(shù)據(jù)庫訪問和處理數(shù)據(jù)的標準計算機語言無論用的是什么數(shù)據(jù)庫(MySql,Oracle,MS SQL),都使用SQL語言對數(shù)據(jù)庫中的數(shù)據(jù)進行管理重點學(xué)習(xí)如何用SQL進行數(shù)據(jù)的查詢、添加、刪除與修改MySQL數(shù)據(jù)的組織形式數(shù)據(jù)庫數(shù)據(jù)表1一行行的數(shù)據(jù)一行行的數(shù)據(jù)數(shù)據(jù)表2數(shù)據(jù)表3一行行的數(shù)據(jù)MySQL的安裝安

2、裝MySql使用mysql.exe在命令行模式下對數(shù)據(jù)庫進行管理MySql的默認用戶rootMysql u root -pSQL語言初步創(chuàng)建數(shù)據(jù)庫語法:create database database_name;create database ExpenseNote;創(chuàng)建完成數(shù)據(jù)庫后,需要選中此數(shù)據(jù)庫方可進行其他操作語法:use database_name;use ExpenseNote;數(shù)據(jù)表的結(jié)構(gòu)編號(Id)開支類型(type)日期(time)明細(content)金額(amount)1吃飯2012-3-1食堂8.52網(wǎng)購2012-3-2專業(yè)書503超市2012-3-3泡面10.我的生活開

3、支表注意到:1.每一列的數(shù)據(jù)類型是不同的2.有些列內(nèi)容是可選的,有些則不是MySql數(shù)據(jù)類型常用的數(shù)據(jù)類型有:整形:int浮點:float文本:varchar(length)日期:date創(chuàng)建數(shù)據(jù)表要點:想要創(chuàng)建數(shù)據(jù)表,需要準確描述數(shù)據(jù)表的各列的名稱、數(shù)據(jù)類型與其他屬性(是否允許空值等)語法create table table_name(column1_namedata_type not null other_property, column2_namedata_type not null other_property, );create table expensenote(idint pri

4、mary key not null auto_increment,typevarchar(10) not null,contentvarchar(255), timedate not null,amountfloat not null);插入數(shù)據(jù)Insert向數(shù)據(jù)表中插入數(shù)據(jù)語法:insert into table_name(column1,column2,columnn) values(column1_data,column2_data,column_data);或者:insert into table_name values();按照數(shù)據(jù)表中列的順序依次添加數(shù)據(jù)例:insert into

5、expenses(type,content,amount,time) values(網(wǎng)購,專業(yè)書,50.80,2012-3-3);SQL檢索數(shù)據(jù)select注意,數(shù)值型數(shù)據(jù)不需要加引號,字符型、日期型需要加單(或雙)引號。從指定數(shù)據(jù)表中檢索數(shù)據(jù)語法:select * from table_name where clause;select * from expensenote;select * from expensenote where amount 50;select * from expensenote where time=2012-3-1 and time = 2012-3-31;se

6、lect * from expensenote limit 5;SQL修改數(shù)據(jù)Update修改數(shù)據(jù)updateUPDATE table_name SETcolumn1_name = data1_value where clausecolumn2_name = data2_value where clause;例:update expensenote set amount = 10.0 where id = 1;注意:如果不加條件語句,就會修改所有數(shù)據(jù)行!SQL刪除數(shù)據(jù)Delete刪除某條數(shù)據(jù)語法DELETE FROM table_name where clause例:delete FROM expensenote where id = 1;delete FROM expensenote where date = 2012-5-1 or date = 2

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論