對資料庫進行操作

2021-10-22 14:27:03 字數 2300 閱讀 5329

對資料庫進行操作

一、ddl:資料庫定義語言 對資料庫、表結構進行操作 建庫、建表、修改表結構、刪庫、刪表等等

(sql語句大小寫不敏感)

1.建立資料庫

2.顯示所有的資料庫

3.切換到要使用的資料庫, use 資料庫名稱;

4.4.刪除資料庫!

drop database [if exists] 資料庫名;

5.建表

5.建表

create table [if not exists] tablename(欄位名 字段型別,....)[charset=utf8];

6.顯示當前資料庫下所有的表

7.顯示建表語句

show create table 表名;

8.為表中增加列

alter table 表名 add 欄位名 字段型別;

alter table 表名 add (欄位名 字段型別,...)

9.修改列定義

alter table 表名 modify 欄位名 新字段型別;

alter table student modify *** text;

alter table 表名 change 舊列名 新列名 新列定義;

alter table student change *** 性別 varchar(5);

modify無法修改列名,change可以修改列名

10.刪除列

alter table 表名 drop 列名;

alter table student drop 性別;

11.刪表

drop table [if exists] 表名;

drop table student;

Python對資料庫進行操作

步驟三 編寫python指令碼,下例只是做了個查詢 具體使用要結合你的需求進行對資料庫操作,然後對操作結果進行校驗和下部操作。usr bin python coding utf 8 import mysql.connector import mysqldb conn mysqldb.connect ...

如何用eql語句對資料庫進行操作

string sql select from xx x string wheres if c.length string型別 if z if wheres.length 0 sql wheres i sql order by x.created desc asc 這部分是查詢出來的條件按照建立時間來...

對資料庫的操作

資料庫的檔案 資料檔案 包含資料和物件,主資料檔案建議副檔名.mdf,其餘.ndf 事務日誌檔案 包含恢復資料庫中的所有事物所需的資訊,建議副檔名.ldf 至少包含乙個資料檔案和乙個日誌檔案 對資料庫的操作 選其中乙個,可以選 選其中乙個,必選 分割,表示多個選項 表示說明 建立create dat...