MySQL 資料的增刪改查

2022-08-01 10:27:13 字數 994 閱讀 2925

一、

在mysql管理軟體中,可以通過sql語句中的dml語言來實現資料的操作,包括

1.使用insert實現資料的插入

2.update實現資料的更新

3.使用delete實現資料的刪除

4.使用select查詢資料以及。

二、插入資料 insert

1. 插入完整資料(順序插入)

語法一:

insert into 表名(欄位1,欄位2,欄位3…欄位n) values(值1,值2,值3…值n);

語法二:

insert into 表名 values (值1,值2,值3…值n);

2. 指定字段插入資料

語法:insert into 表名(欄位1,欄位2,欄位3…) values (值1,值2,值3…);

3. 插入多條記錄

語法:insert into 表名 values

(值1,值2,值3…值n),

(值1,值2,值3…值n),

(值1,值2,值3…值n);

4. 插入查詢結果

語法:insert into 表名(欄位1,欄位2,欄位3…欄位n)

select (欄位1,欄位2,欄位3…欄位n) from 表2

where …;

三、更新資料update

語法: update 表名 set

欄位1=值1,

欄位2=值2,

where condition;

示例: update mysql.user set password=password(『123』)

where user=』root』 and host=』localhost』;

四、刪除資料delete

語法: delete from 表名

where conition;

示例: delete from mysql.user

where password=』』;

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 ...

Mysql資料增刪改查

建立資料庫表 haha 並寫入字段 create table haha user name varchar 32 age int,sin date date 向字段寫入資料 insert into xx value xixi 12 2016 12 12 insert into xx values w...