首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > Mysql >

mysql 根本操作命令

2013-11-08 
mysql基本操作命令1.查看端口Netstat –an2.登陆mysql服务器Mysql –u root –pmysql–hlocahost –u root –p3.

mysql 基本操作命令

1.         查看端口

             Netstat –an

2.         登陆mysql服务器

             Mysql –u root –p         mysql–hlocahost –u root –p

3.         选择数据库

            Show databases  

4.         设置字符集

            set names 'gbk';

5.         查询数据库中的表

             show tables;

6.      设置字符集

             set names'gbk';

7.      创建表

          create tabletest(

          tid int(10) not null,

          tname varchar(100) notnull,

          tdate datetime not null default'0000-00-00',

          primary key(tid));

8.         查看表结构

          desc test;

9.         增加列

          alter table testadd(tage int(3));

10.      修改列的默认值

          alter table test altertag set default '0';

11.    删除默认值

          alter table test altertag drop default;

12.    删除列

           alter table test dropcolumn tag;

13.      插入数据

           insert intotest(tid,tname,tdate) value(1,'ymm','2012-11-04');

14.    删除表

         drop table test;

15.    修改表名

         alter tabletest rename test1;

16.      显示数据库版本

          select version();

17.    刷新数据库

          flush privileges;

18.    查询当前时间

           select current_date;

19.    将查询出的数据写入文件

          select * from test1into outfile "F:/test.txt" fields terminated by ",";

20.     查看数据库状态

            status;

21.    MySQL基本操作查看所有编码

           show variables like'character_set_%';

 22.   主键设置自子增长

          tid int(10) not nullauto_increment,//设置主键的时候 

          alter table auto auto_increment=(10);

 

 

 

热点排行