修改,刪除資料庫表

2021-10-08 15:28:06 字數 703 閱讀 7657

– 修改表名:舊的表名tehels 新的表名teacher

alter table tehels rename as teacher add 欄位名 列屬性

– 增加表的字段:alter table 表名

alter table teacher add id int(10)

– 修改表的字段(重新命名,修改約束)

alter table 表名 modify 欄位名 [ 列屬性]

alter table teacher modify id varchar (11)-- 修改約束

alter table 表名 change 舊名字 新名字 [ 列屬性]

alter table teacher change id age int(1) --欄位重新命名

–刪除表的字段:alter table 表名 drop 欄位名

alter table teacher drop age

刪除表:-- 刪除表(如果表存在再刪除)

drop table if exists teacher

drop table if exists schjsj

所有的建立和刪除操作,盡量加上判斷,以免報錯

注意點1: ··欄位名,使用這個包裹!

2: 注釋 – /**/

3: sql 關鍵字大小寫不敏感,建議小寫

4:所有的符號用英文

資料庫修改,刪除資料 總結

修改資料和新增資料沒有什麼大的區別 修改就是重新新增 步驟 一 首先修改資料二 定義三個變數 結果集字串 字串 dim txtsql as string dim msgtext as string dim mrcc as adodb.recordset 三 判斷資料有效性四 刪除要修改的資料 記得一...

資料庫修改,刪除資料 總結

修改資料和新增資料沒有什麼大的區別 修改就是重新新增 步驟 一 首先修改資料二 定義三個變數 結果集字串 字串 dim txtsql as string dim msgtext as string dim mrcc as adodb.recordset 三 判斷資料有效性四 刪除要修改的資料 記得一...

Flask SQLAlchemy 修改 刪除資料

在使用first 或者all 等方法返回資料之前,呼叫 update 方法可以修改已存在的資料值。user.query.filter by username admin update 資料模型的修改已被自動加入session中 db.session.commit 如果我們要從資料庫中刪除一條資料,則...