PHP中常用的幾個 mysql操作
更新時間:2015年04月24日 11:51:03 投稿:hebedich
本篇文章是對關(guān)于php操作mysql執(zhí)行數(shù)據(jù)庫查詢的一些常用操作進行了詳細的匯總介紹,非常的細致全面,也很簡單,需要的朋友參考下
顯示數(shù)據(jù)庫或表:
復(fù)制代碼 代碼如下:
show databases;//然后可以use database_name;
show tables;
更改表名:
復(fù)制代碼 代碼如下:
alter table table_name rename new_t;
添加列 :
復(fù)制代碼 代碼如下:
alter table table_name add column c_n column attributes;
刪除列:
復(fù)制代碼 代碼如下:
alter table table_name drop column c_n;
創(chuàng)建索引:
復(fù)制代碼 代碼如下:
alter table c_table add index (c_n1,c_n2);
alter table c_table add unique index_name(c_n);
alter table c_table add primary key(sid);
刪除索引:
復(fù)制代碼 代碼如下:
alter table c_table drop index c_n1;
更改列信息:
復(fù)制代碼 代碼如下:
alter table t_table change c_1 c_1 varchar(200);
alter table t_table modify 1 c_1 varchar(200);
insert插入語句:
復(fù)制代碼 代碼如下:
insert into table_name (c_1,c_2)
values ('x1′,1);
update語句:
復(fù)制代碼 代碼如下:
update table_name set c_1 =1 where c_2=3;
刪除數(shù)據(jù)庫或者表:
復(fù)制代碼 代碼如下:
drop table table_name;
drop database database_name;//使用mysql_drop_db()可以刪除的.
相關(guān)文章
MySQL5.7更改密碼時出現(xiàn)ERROR 1054 (42S22)的解決方法
這篇文章主要為大家詳細介紹了MySQL5.7更改密碼時出現(xiàn)ERROR 1054 (42S22)的解決方法,具有一定的參考價值,感興趣的小伙伴們可以參考一下2019-10-10
解決mysql報錯:Data?source?rejected?establishment?of?connect
這篇文章主要給大家介紹了關(guān)于如何解決mysql報錯:Data?source?rejected?establishment?of?connection,?message?from?server:?\"Too?many?connectio的相關(guān)資料,文中通過實例代碼介紹的非常詳細,需要的朋友可以參考下2023-02-02
mysql?DISTINCT選取多個字段,獲取distinct后的行信息方式
這篇文章主要介紹了mysql?DISTINCT選取多個字段,獲取distinct后的行信息方式,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教2024-01-01
Mysql8報錯this is incompatible with sql_mo
這篇文章主要介紹了Mysql8報錯this is incompatible with sql_mode=only_full_group_by問題,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教2024-01-01

