mysql 學習筆記06

2021-08-25 02:22:33 字數 660 閱讀 2069

環境 :linux系統

1.source的使用

作用:用於匯入sql檔案

注意點:

cd desktop --目標目錄進入你需要匯入sql檔案的目錄(資料夾)

mysql -uroot -p在此目錄下進入mysql

create table 表名(欄位...)建立需要匯入sql檔案對應的表

source mm.sql執行匯入語句完成

2.備份

2.1.執行mysqldump命令

mysqldump –uroot –p 資料庫名 > python.sql

;

注意點:

1.cd desktop執行備份命令時需要退出mysql才能執行,不是在在mysql終端執行的

3.恢復

mysql -uroot –p 新資料庫名 < python.sql

# 根據提示輸入mysql密碼

注意點:

執行備份命令時需要退出mysql才能執行,不是在在mysql終端執行的

匯入python.sql前需要在mysql資料中建乙個新資料庫,用於存放匯入sql檔案

MySQL學習筆記 06 約束

分類 1.主鍵約束 primary key 2.非空約束 not null 3.唯一約束 unique 4.外來鍵約束 foreign key 1.建立表時新增約束 create table stu id int,name varchar 20 not null name為非空 2.建立表完後,新增...

mysql 學習筆記 day06

檢視操作 create alter view name as select column name from table name 事物操作 原子性 一致性隔離性 永續性 create table class id int primary key auto increment,cz money de...

學習筆記06

do while 水仙花 從100到999 各個位數的立方和相加等於這個數本身就是乙個水仙花數 include intmain void i while i 999 return0 pow 用來計算以x為底的y次方值 include 上述式子可改為 if pow a,3 pow b,3 pow c,...