1、插入数据到table_name表

INSERT INTO table_name ( field1, field2,...fieldN )
                       VALUES
                       ( value1, value2,...valueN );

2、将amoeba101.a_account_change表中数据,主键ID为2331的数据复制插入到amoeba101.test103表中

insert into amoeba101.test103 select * from amoeba101.a_account_change  where changeId=2331 LIMIT 10000;


3、update更新操作

mysql> UPDATE runoob_tbl SET runoob_title='学习 C++' WHERE runoob_id=3;
Query OK, 1 rows affected (0.01 sec)
 
mysql> SELECT * from runoob_tbl WHERE runoob_id=3;
+-----------+--------------+---------------+-----------------+
| runoob_id | runoob_title | runoob_author | submission_date |
+-----------+--------------+---------------+-----------------+
| 3         | 学习 C++   | RUNOOB.COM    | 2016-05-06      |
+-----------+--------------+---------------+-----------------+
1 rows in set (0.01 sec)

4、查询表中所有的字段
mysql> show full columns from test101;
+----------------+---------------+-----------------+------+-----+---------+-------+---------------------------------+-----------------------------------+
| Field          | Type          | Collation       | Null | Key | Default | Extra | Privileges                      | Comment                           |
+----------------+---------------+-----------------+------+-----+---------+-------+---------------------------------+-----------------------------------+
| changeId       | varchar(32)   | utf8_general_ci | NO   | PRI |         |       | select,insert,update,references | 账变编号                          |
| memberId       | bigint(20)    | NULL            | YES  | MUL | NULL    |       | select,insert,update,references | 会员编号                          |
| groupId        | varchar(500)  | utf8_general_ci | YES  |     | NULL    |       | select,insert,update,references | 代理组编号                        |
                        | 
| erCode         | varchar(32)   | utf8_general_ci | YES  |     | NULL    |       | select,insert,update,references | 订单编号                          |
+----------------+---------------+-----------------+------+-----+---------+-------+---------------------------------+-----------------------------------+

5、like语句
mysql> use RUNOOB;
Database changed
mysql> SELECT * from runoob_tbl  WHERE runoob_author LIKE '%COM';
+-----------+---------------+---------------+-----------------+
| runoob_id | runoob_title  | runoob_author | submission_date |
+-----------+---------------+---------------+-----------------+
| 3         | 学习 Java   | RUNOOB.COM    | 2015-05-01      |
| 4         | 学习 Python | RUNOOB.COM    | 2016-03-06      |
+-----------+---------------+---------------+-----------------+
2 rows in set (0.01 sec)2
打赏作者

Leave a Reply

Your email address will not be published.