手机站
网通分站
电信主站
密 码:
用户名:
当前位置 : 主页>网络编程>Mysql>列表

MySQL多表操作和备份处理

来源:互联网 作者:west263.com 时间:2008-02-23
西部数码-全国虚拟主机10强!40余项虚拟主机管理功能,全国领先!双线多线虚拟主机南北访问畅通无阻!免费赠送企业邮局,.CN域名,自助建站480元起,免费试用7天,满意再付款! P4主机租用799元/月.月付免压金!
mysql> insert into mytable -> values (′abc′,′f′,′1966-08-17′,′china′,′n′); Query OK, 1 row affected (0.05 sec)

查看一下:

mysql> select * from mytable; 

 ---------- ------ ------------ ----------- --------  

| name | sex | birth | birthaddr | single | 

 ---------- ------ ------------ ----------- --------  

| abccs |f | 1977-07-07 | china | y | 

| mary |f | 1978-12-12 | usa | NULL | 

| tom |m | 1970-09-02 | usa | NULL | 

| abc |f | 1966-08-17 | china | n | 

 ---------- ------ ------------ ----------- -------- 


4、删除记录

用如下命令删除表中的一条记录:mysql> delete from mytable where name=′abc′;

DELETE从表中删除满足由where给出的条件的一条记录。

再显示一下结果:

mysql> select * from mytable; 

 ---------- ------ ------------ ----------- --------  

| name | sex | birth | birthaddr | single | 

 ---------- ------ ------------ ----------- --------  

| abccs |f | 1977-07-07 | china | y | 

| mary |f | 1978-12-12 | usa | NULL | 

| tom |m | 1970-09-02 | usa | NULL | 

 ---------- ------ ------------ ----------- -------- 


5、删除表:

mysql> drop table ****(表1的名字),***表2的名字;

能够删除一个或多个表,小心使用。

6、数据库的删除:

mysql> drop database 数据库名;

小心使用。

7、数据库的备份:

退回到DOS:

mysql> quit

d:mysqlbin

使用如下命令对数据库abccs进行备份:

mysqldump --opt abccs>abccs.dbb

abccs.dbb就是您的数据库abccs的备份文档。

8、用批处理方式使用MySQL:

首先建立一个批处理文档mytest.sql,内容如下:

use abccs; 

select * from mytable; 

select name,sex from mytable where name=′abccs′;


在DOS下运行如下命令:d:mysqlbin mysql < mytest.sql

在屏幕上会显示执行结果。

假如想看结果,而输出结果很多,则能够用这样的命令: mysql < mytest.sql | more

我们还能够将结果输出到一个文档中: mysql < mytest.sql > mytest.out

文章整理:西部数码--专业提供域名注册虚拟主机服务
http://www.west263.com
以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!