修改删除MySQL数据库中的数据内容:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
[root@hk ~]# /usr/local/mysql/bin/mysql -uroot -p'admin' #进入mysql mysql> create database gbk default character set gbk collate gbk_chinese_ci; #建立一个名字叫做gbk的数据库 mysql> use gbk mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | gbk | +--------------------+ mysql> show tables; Empty set (0.00 sec) mysql> create table test( #建立一个叫做test的数据表 -> id int(4) not null primary key auto_increment, -> name char(20) not null -> ); Query OK, 0 rows affected (0.13 sec) mysql> show tables; +---------------+ | Tables_in_gbk | +---------------+ | test | +---------------+ 1 row in set (0.00 sec) mysql> insert into test(id,name) values(1,'zy'); #插入部分内容 mysql> insert into test(id,name) values(2,'binghe'); mysql> insert into test(id,name) values(3,'zilong'); mysql> insert into test(id,name) values(4,'feng'); mysql> select * from test; #检索整个test表 +----+--------+ | id | name | +----+--------+ | 1 | zy | | 2 | binghe | | 3 | zilong | | 4 | feng | +----+--------+ 4 rows in set (0.00 sec) [root@hk ~]# /usr/local/mysql/bin/mysqldump -uroot -p'admin' -B gbk >/tmp/gbk.sql #备份gbk数据库 mysql> update test set name = 'zy' ; #未定义 mysql> select * from test; # +----+------+ | id | name | +----+------+ | 1 | zy | | 2 | zy | | 3 | zy | | 4 | zy | +----+------+ [root@hk ~]# /usr/local/mysql/bin/mysql -uroot -p'admin' mysql> use gbk mysql> select * from test; +----+--------+ | id | name | +----+--------+ | 1 | zy | | 2 | binghe | | 3 | zilong | | 4 | feng | +----+--------+ mysql> update test set name = 'yadianna' where id =1; mysql> select * from test; +----+----------+ | id | name | +----+----------+ | 1 | yadianna | | 2 | binghe | | 3 | zilong | | 4 | feng | +----+----------+ mysql> update test set id = 999 where name ='yadianna'; mysql> select * from test; +-----+----------+ | id | name | +-----+----------+ | 2 | binghe | | 3 | zilong | | 4 | feng | | 999 | yadianna | +-----+----------+ mysql> delete from test where id =999; mysql> select * from test; +----+--------+ | id | name | +----+--------+ | 2 | binghe | | 3 | zilong | | 4 | feng | +----+--------+ mysql> delete from test where id <4; #以条件删除 mysql> truncate table test; #删除all mysql> select * from test; Empty set (0.00 sec) |
申明:本文由BYRD原创(基于Mysql5.6.16),未经许可禁止转载!SourceByrd's Weblog-https://note.t4x.org/database/modify-delete-database-table/ SourceByrd's Weblog-https://note.t4x.org/database/modify-delete-database-table/
申明:除非注明Byrd's Blog内容均为原创,未经许可禁止转载!详情请阅读版权申明!
Trackbacks