MySQL學習筆記_1_MySQL資料庫管理系統概述,學習筆記_1_mysql

來源:互聯網
上載者:User

MySQL學習筆記_1_MySQL資料庫管理系統概述,學習筆記_1_mysql


1、 MySQL架構

C/S: client / server架構

MySQL DBMS(Data Bank Management System): 資料庫管理系統

用戶端 <---> 伺服器 ---> 資料庫 ---> 資料表 ---> (記錄/行,欄位/列)


2、 資料庫程式員需要精通的操作:(不是DBA(資料庫管理員))

一、為項目設計表

二、使用SQL語句(SQL語句編程)

其他、都可以通過工具來完成。

3、MySQL檔案結構

  設定檔:my.ini: 可以通過修改該檔案,來配置MySQL相應的屬性

bin檔案目錄: 儲存了MySQL所有的命令

data檔案目錄: 儲存了MySQL所包含的庫,各個庫裡麵包含的是相應的 表!

【備份時,只需將data檔案夾打包備份出去就可以了,Linux下為var/】

4、SQL語句操作

SQL(Structured Query Language)是一種進階的非過程化的語言。

SQL語句:結構簡單,功能強大,簡單易學!

按功能劃分:

DDL:建立資料庫,資料表的語句

DML:操作資料的語句

DQL:資料庫查詢語句

DCL:資料控制的語句,可以工具執行。

如: \s 查看狀態

show databases; 查看所有庫

show tables;  查看所有表

desc tables; 查看錶結構

show variables; 查看設定檔中的變數

DDL: 1、執行SQL語句,首先要串連到資料庫伺服器上:

mysql -h localhost -u root -p #以root使用者登入到本機資料庫

\s:查看資料庫狀態

show variables;:查看系統中預設配置的變數,謹記:以;結束

show variables like 'time_zone';

show variables like 'port'; : 查看連接埠

show databases; : 顯示系統中所有的庫

2、建立資料庫

create database [name];

如: create database boost;

3、刪除資料庫

drop database [name];

如: drop datebase boost;

  拓展: cteate database if not exists boost;

drop database if exists boost;

4、建立一張資料表

create table boost.users(id int,name char(30),age int,sex char(3)); 

5、選擇一個庫作為預設資料庫

use boost;

6、查看所有的表

show tables;

7、查看錶結構

desc users;

8、刪除表

drop table users; // drop table if exists users;

9、繼續在預設資料庫中建立

create table users(id int,name char(32),age int,sex char(2));

拓展:

       create table is not exists users(id int,name char(32));

10、再建立一張表

create table is not exists articles(title char(64));

DML: 11、插入資料

insert into users values('2012','xiaofang','34','nan');

或:  insert into users values(2012,'xiaofang',34,'man'); //弱類型檢查

最佳實務: insert into users(id,name,age) values('2334','wangwu','56');

即可插入部分,又可不按順序插入。

12、更新資料資訊

update users set name='AShun' where id='2012';

推廣: update users set name='XiaoChang',sex='Nv' where id='2012';

13、刪除資料資訊

delete from users where id='2012';

推廣: delete from users //全部刪除

DQL: 14、查看資料資訊,查詢語句

select * from users;

5、協助的使用

1、查看協助所能夠提供的資訊

? contents;

2、進一步查看詳細資料

? data types; //需是上面所列出的資訊類型

3、更進一步查看具體資訊

? int;

? show;

? create tables; // 查看建立表結構文法

? update;


轉載 

如有著作權問題,請聯絡QQ:858668791

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.