Alter table my_table add column col type1添加主键

Alter table my_table add primary key(col)1删除主键

Alter table my_table drop primary key(col)1创建索引

create [unique] index inx on my_table(col...)1删除索引

drop index inx1创建视图

create view my_view as select statement1删除视图

drop view my_view1常用的 sql 基本语句

选择:select from my_table where 条件插入:insert into my_table (field1,field2) values (value1,value2)删除:delete from my_table where 条件变动:update my_table set field1 = value1 where 条件查找:select from my_table where field1 like ‘%value1’排序:select from my_table order by field1,field2 [desc]总数:select count as totalcount form my_table求和:select sum(field1) as sumvalue from my_table均匀:select avg(field1) as avgvalue from my_table最大:select max(field1) as maxvalue from my_table最小:select min(field1) as minvalue from my_table

PHP 操作 mysql 数据库

1.链接数据库

$conn=@mysql_connect("localhost","root","root");if(!$conn){die("数据库连接失落败",mysql_error())}else{echo"数据路连接成功"}123456

2.选择数据库

phpmysql命令MySQL技巧数据库基本操作敕令年夜全建议珍藏 RESTful API

mysql_select_db("web",$conn)1

3.实行 sql 语句

$query=mysql_query("select from 表名 where 1")1

4.操作 sql 结果

while($row=mysql_fetch_assoc($result)){print_r($row);echo "<br>";}1234

5.关闭 mysql 链接

mysql_close($conn)

须要的可以按照以下办法免费领取1、关注我,转发+评论2、私信发送:【学习】,即可领取!