MySQL 增刪改查操作

2021-10-07 18:23:21 字數 1130 閱讀 4519

@toc

--登入資料庫

mysql -u root -p123456

--建立資料庫

creat database test;

--檢視所有資料庫

show

databases

;--檢視資料庫中所有的資料表

show

tables

;--選中資料庫

usedatabases

;--建立資料表

create

table pet (

name varchar(20

),owner varchar(20

),species varchar(20

),*** char(1

),birth date

,death date);

--檢視資料表

show

tables;

--檢視資料表結構

describe pet;

--往資料表中插入資料

insert

into pet values

('puffball'

,'diane'

,'hamster'

,'f'

,'1993-03-30'

,null);

insert

into pet values

('旺財'

,'周星馳'

,'狗'

,'公'

,'1988-01-01'

,null);

--mysql常用資料型別

--三大型別:數值,日期,字串

--日期選擇按照格式2020-01-01

--字元選擇按照大小

--刪除資料

delete

from pet where name=

'puffball'

;--修改資料

update pet set name=

'旺旺猜'

where owner=

'周星馳'

;--增刪改查

insert

,delete

,update

,select

MySQL增刪改查操作

增刪改查操作 查詢表中的所有的記錄 select from 表名 xs 建立資料庫 create database if not exists xsgl 8.2建立表 cerate table if not exists 判斷是否存在 表名 xsb 8.3刪除 drop database if ex...

mysql增刪改查效果 mysql增刪改查

檢視所有資料庫 mysql show databases 建立乙個庫ghd並指定字符集為utp8 mysql create database ghd charset utf8 檢視mysql支援的字符集 mysql show char set 建立乙個表,並設定id為主鍵 create table ...

mysql增刪改查擴充套件 MySQL增刪改查

1 插入 insert 1 insert into 表名 values 值1 值2 例子 insert into t1 values zengsf 23 fengshao 22 2 insert into 表名 欄位1,values 值1 例子 insert into t1 name values ...