Chinaunix首页 | 论坛 | 博客

acc

  • 博客访问: 791647
  • 博文数量: 170
  • 博客积分: 7011
  • 博客等级: 少将
  • 技术积分: 1660
  • 用 户 组: 普通用户
  • 注册时间: 2006-07-31 12:02
文章分类

全部博文(170)

文章存档

2014年(7)

2010年(2)

2009年(62)

2008年(25)

2007年(67)

2006年(7)

我的朋友

分类: Mysql/postgreSQL

2008-10-24 17:08:53

mysql5.0 命令集锦

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
匹配字符:可以用通配符_代表任何一个字符,%代表任何字符串;
多行命令输入:注意不能将单词断开;当插入或更改数据时,不能将字段的字符串展开到多行里,否则硬回车将被储存到数据中;
每条语句输入完毕后要在末尾填加分号';',但是有的不加也行,加了反而会有BUG;或者填加'\g'也可以;
 
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 
启动mysql:net start mysql
停止mysql:net stop mysql
退出mysql:exit
登录mysql:mysql -u root -p/mysql -h localhost -u root -p databaseName
列出数据库:show databases;
选择数据库:use databaseName
列出表格:show tables;
显示表格列的属性:show columns from tableName;
增加一个字段:alter table tabelName add column fieldName dateType;
增加多个字段:alter table tabelName add column fieldName1 dateType,add column fieldName2 dateType;
查询时间:select now();
查询当前用户:select user();
查询数据库版本:select version();
查询当前使用的数据库:select database();
增加一个管理员帐户:grant all on *.* to identified by "password";  (userName为用户名)
备份数据库:(将数据库test备份)
  mysqldump -u root -p test>c:\test.txt
  备份表格:(备份test数据库下的mytable表格)
  mysqldump -u root -p test mytable>c:\test.txt
  将备份数据导入到数据库:(导回test数据库)
  mysql -u root -p test
创建表是先判断表是否存在
  create table if not exists students(……);
复制表
  create table table2 select * from table1;
对表重新命名
  alter table table1 rename as table2;
修改列的类型
  alter table table1 modify id int unsigned;//修改列id的类型为int unsigned
  alter table table1 change id sid int unsigned;//修改列id的名字为sid,而且把属性修改为int unsigned
 
 
 
阅读(1164) | 评论(0) | 转发(0) |
0

上一篇:版本常识

下一篇:关于JAVA中的equals()和==

给主人留下些什么吧!~~