当前位置:首页 > 网络编程 > 数据库 > Mysql > php教程:mysql的常用语句

php教程:mysql的常用语句

点击次数:33 次 发布日期:2008-11-22 09:06:34 作者:源代码网
源代码网推荐

源代码网整理以下关于 PHP 教程的文章已经很多了,今天给大家介绍几个常用的MYSQL语句。

源代码网整理以下显示数据库或表:

源代码网整理以下

以下为引用的内容:
    show databases;//然后可以use database_name;
    show tables;

源代码网整理以下更改表名:

源代码网整理以下

   alter table table_name rename new_t;

源代码网整理以下添加列 :

源代码网整理以下

 alter table table_name add column c_n column attributes;

源代码网整理以下删除列:

源代码网整理以下

 alter table table_name drop column c_n;

源代码网整理以下创建索引:

源代码网整理以下

    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); Webjx.Com

源代码网整理以下
删除索引:

源代码网整理以下

   alter table c_table drop index c_n1;

源代码网整理以下更改列信息:

源代码网整理以下 

    alter  table t_table change c_1 c_1 varchar(200);
    alter table t_table modify 1 c_1 varchar(200);

源代码网整理以下insert插入语句:

源代码网整理以下

   insert into table_name (c_1,c_2)
        values ("x1",1);

源代码网整理以下update语句:

源代码网整理以下

  update  table_name set c_1 =1 where c_2=3;

源代码网整理以下删除数据库或者表:

源代码网整理以下

    drop table table_name;
    drop database database_name;//使用mysql_drop_db()可以删除的.

源代码网供稿.
网友评论 (0)
会员中心
网络编程
本站推荐
网络编程之精华