DB2中列加上后数据类型也不改变,唯一能改变的是增 加 varchar 类型的长度。
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_tablePHP *** 作 mysql 数据库1.链接数据库$conn=@mysql_connect("localhost","root","root");if(!$conn){die("数据库连接失败",mysql_error())}else{echo"数据路连接成功"}1234562.选择数据库mysql_select_db("web",$conn)13.执行 sql 语句$query=mysql_query("select * from 表名 where 1")14. *** 作 sql 结果while($row=mysql_fetch_assoc($result)){print_r($row);echo "<br>";}12345.关闭 mysql 链接mysql_close($conn)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)