資料庫的操作

2021-08-27 04:00:02 字數 1266 閱讀 5738

一、基本操作

1、建立資料庫

鏈結資料庫

mysql -uroot

-p+(密碼)

退出

quit/exit
建立

create

database ab_name charset=utf8;

2、選擇資料庫

進入資料庫 use ab_name ;

檢視當前所選的資料庫: select

database();

3、建立表

建立乙個顧客表

create

table customer(id int

primary

key auto_increment not

null,

name varchar(10) not

null,

password varchar(10) not

null,

gender enum('boy','girl','secret'),

active int

default

0);

4、檢視資料庫裡的表

show tables;
5、檢視表的結構

desc customer(表名)
6、刪庫操作

drop

database ab_name;

7、增加字段

alter

table customer add email varchar(20) not

null;

8、修改字段

alter

table customer change name user_name varchar(20) not

null;

9、刪除字段

alter

table customer drop email;

10、刪除表

drop

table customer

資料庫 基礎資料庫的操作

什麼是資料庫 資料庫 database 是按照資料結構來組織 儲存和管理資料的倉庫 常見的資料庫oracle mysql sun db2 ibm sql server microsoft postgre sql 專業術語 資料庫系統 database system dbs 資料庫 database ...

資料庫 MySQL 資料庫的操作

1.建立資料庫 create database if notexists 資料庫名 charset 字元編碼 utf8mb4 如果多次建立會報錯 字元編碼不指定預設 utf8mb4 給資料庫命名 定要習慣性加上反引號,防 和關鍵 字衝突 2.檢視資料庫 show databases 3.選擇資料庫 ...

資料庫的操作

一 ddl資料庫操作庫 1.1 建立資料庫 create database 資料庫名 2 檢視建立的資料庫資料 show create database mydb1 3 指定資料庫字符集 create database mydb2 character set gbk 4 檢視資料庫支援的字符集 sh...