**建立表**:
use equipment;
create table ghes(
user varchar(20),
equipment_category varchar(20),
equipment_type varchar(20),
start_up_time datetime(6),
remarks varchar(50),
id int not null auto_increment,
primary key(id));
**向表中插入資料:**
insert into ghys(user,equipment_category,equipment_type,start_up_time) values("王燕","相容機","至強e3",
"2015-04-01")
**批量修改字段值:**
update ghys set equipment_type = replace(equipment_type,'至強e3','至強e3 1232')where id
<4;
**如何刪除一條記錄:**
delete from ghes where id=7;
**新增欄位並賦值:**
alter table equipment.szfy add usage_state varchar(10) default '正在使用';
alter table equipment.szfy add department varchar(10) default '市政分院' after id; 注:在某一字段前賦值
**多表查詢:**
select * from equipment.cwb union select * from equipment.ghes union select * from equipment.ghys union select * from equipment.ghss union select * from equipment.jszlb
union select * from equipment.jts union select * from equipment.jyb union select * from equipment.jzfy union select * from equipment.rlzyb union select * from equipment.szfy
union select * from equipment.tdb union select * from equipment.xxb union select * from equipment.yld union select * from equipment.zxb order by department;
mysql學習筆記 51 mysql學習筆記
初學mysql時整理,隨時更新 資料操作 增 insert into 表名 字段列表 values 值列表 值列表 如果要插入的值列表包含所有字段並且順序一致,則可以省略字段列表。可同時插入多條資料記錄!replace 與 insert 完全一樣,可互換。insert into 表名 set 欄位名...
mysql學習筆記 51 Mysql 學習筆記
一.首先進入mysql mysql u root p新增使用者許可權設定 grant all privileges on to jerry localhost identified by aa1234567 只允許本機訪問 grant all privileges on to jerry 10.80...
mysql做筆記 mysql學習筆記
alter table 新增,修改,刪除表的列,約束等表的定義。檢視列 desc 表名 修改表名 alter table t book rename to bbb 新增列 alter table 表名 add column 列名 varchar 30 刪除列 alter table 表名 drop ...