mysql學習筆記(四)資料庫及表的修改和刪除

2021-07-26 11:48:59 字數 914 閱讀 5043

額外補充:

1.查詢檔案中所有資料庫 :  show databeses ;

2.進入sql檔案 : source 

正文:1.刪除資料庫 drop  database 資料庫名字 ;  eg : drop database test_01;

2.重新命名一張表:  rename table + 檔名 to 重新命名檔名 ; eg : rename table test01 to test02;

3.刪除一張表 :  drop table + 表名

4.對錶增加一列: alter table + 表名 + add +增加列名 + 資料型別 + 資料型別 + 約束 ;

eg : alter table test01 add height int(4) default 170 ; 增加一列名為height的int型別初始化都為170

5.增加置前一列:alter table employee add test int(10) default 11 first;

6.刪除一列: alter table + 表名字 + drop + 列名字 ;  eg : alter table test01 drop height ;

7.重新命名一列:這個重新命名甚至可以修改列的屬性 : alter table + 表名字 + change + 原列名字 + 新名字 + 資料型別 + 約束 ;

eg : alter table test01 change height shengao int(4) default 170   

8.改變資料型別 : alter table 表名字 modify 列名字 新資料型別;

9.對錶內容進行操作:

(1)修改表中的某個值:update 表名字 set 列1=值1,列2=值2 where 條件;

(2)刪除一行:delete from 表名字 where 條件;

mysql資料庫學習筆記(四) 屬性

一 通過命令 備份資料 通過cmd mysqldump uroot p密碼 需要備份的資料庫名 備份後的sql指令碼名 還原資料 首先進入mysql環境 建立乙個庫 在庫下還原資料 通過命令 source 備份的資料庫指令碼 二 通過sqlyog 選中需要備份的資料庫 右鍵 備份 匯出 轉儲到sql...

mysql學習筆記(四) 資料庫表的增刪改基本操作

dml 增刪改基本 create table student id int auto increment primary key name varchar 10 varchar 10 插入資料 insert into student id,name values 1,lilei 插入一條資料 ins...

Mysql學習筆記(四)聊聊資料庫索引

小心情 可直接跳到分割線後 今天心情好些了。一些濃的化不開的壞情緒,也漸漸的在晚上解決掉乙個複雜的邏輯問題後,漸漸消散了。今天中午去吃飯的時候,坤哥漫不經心的說 我這麼多年終於悟出了乙個道理,人年輕的時候不要那麼拼命,都沒有時間做其他事情了 我問什麼其他事情,坤哥看了我一眼,又繼續漫不經心的說,那麼...