Mysql??????????÷?С??
????????? ???????[ 2016/9/29 15:02:43 ] ????????????? MySQL
????????
????1.????????
????2.????????
????3.?????
????4.??????
????????????????students
????????????????class1
?????????????
????id ???? ?????? ?????λ SMALLINT????
????name VARCHAR(30)???? ??? ?
????school VARCHAR(30) ??? ????chengdu college
???????????£?
????1.?????????
????mysql> CREATE DATABASE students;
????Query OK?? 1 row affected (0.07 sec)
????2.?????????
????mysql> USE students;
????Database changed
????3.?????
mysql> CREATE TABLE class1 (
-> id SMALLINT UNSIGNED AUTO_INCREMENT ??
-> name VARCHAR(30) NOT NULL UNIQUE KEY ??
-> school VARCHAR(30) DEFAULT 'chengdu_collage' ??
-> PRIMARY KEY(id)
-> );
Query OK?? 0 rows affected (0.09 sec)
????4.?????
mysql> DESC class1;
+--------+----------------------+------+-----+-----------------+----------------+
| Field | Type | Null | Key | Default | Extra |
+--------+----------------------+------+-----+-----------------+----------------+
| id | smallint(5) unsigned | NO | PRI | NULL | auto_increment |
| name | varchar(30) | NO | UNI | NULL | |
| school | varchar(30) | YES | | chengdu_collage | |
+--------+----------------------+------+-----+-----------------+----------------+
3 rows in set (0.00 sec)
????1.????(INSERT)
1.INSERT INTO tb_name [(col_name...)] {VALUES|VALUE}({expr | DEFAULT}??....)??(...)...
?????
mysql> INSERT INTO class1 (name) VALUES ('john');
Query OK?? 1 row affected (0.01 sec)
mysql> INSERT INTO class1 VALUES (DEFAULT??'jobs'??'chengdu_agricultural_college');
Query OK?? 1 row affected (0.01 sec)
2.INSERT INTO tb_name SET col_name = {expr | DEFAULT}??...
?????
mysql> INSERT INTO class1 SET name='tom';
Query OK?? 1 row affected (0.02 sec)
mysql> INSERT INTO class1 SET name='lues'??school='chengdu_agricultural_college';
Query OK?? 1 row affected (0.01 sec)
????2.???(UPDATE)
1.UPDATE [LOW_PRIORITY] [IGNORE] table_reference
SET col_name1={expr1|DEFAULT} [?? col_name2={expr2|DEFAULT}] ...
?????
mysql> UPDATE class1
-> SET name='lues2' WHERE name='lues';
Query OK?? 1 row affected (0.07 sec)
Rows matched: 1 Changed: 1 Warnings: 0
????3.???(DELETE)
1.DELETE [LOW_PRIORITY] [QUICK] [IGNORE] FROM tbl_name
[WHERE where_condition]
?????
mysql> DELETE FROM class1 WHERE name='lues2';
Query OK?? 1 row affected (0.01 sec)
????4.???(SELECT)
1.?????
mysql> SELECT * FROM class1;
+----+------+------------------------------+
| id | name | school |
+----+------+------------------------------+
| 1 | john | chengdu_collage |
| 2 | jobs | chengdu_agricultural_college |
| 3 | tom | chengdu_collage |
+----+------+------------------------------+
3 rows in set (0.00 sec)
2.???????????
mysql> SELECT * FROM class1 WHERE id > 1;
+----+------+------------------------------+
| id | name | school |
+----+------+------------------------------+
| 2 | jobs | chengdu_agricultural_college |
| 3 | tom | chengdu_collage |
+----+------+------------------------------+
2 rows in set (0.00 sec)
3.?????????
mysql> SELECT * FROM class1 GROUP BY school DESC;
+----+------+------------------------------+
| id | name | school |
+----+------+------------------------------+
| 1 | john | chengdu_collage |
| 2 | jobs | chengdu_agricultural_college |
+----+------+------------------------------+
2 rows in set (0.00 sec)
4.??????????
mysql> SELECT * FROM class1 ORDER BY id DESC;
+----+------+------------------------------+
| id | name | school |
+----+------+------------------------------+
| 3 | tom | chengdu_collage |
| 2 | jobs | chengdu_agricultural_college |
| 1 | john | chengdu_collage |
+----+------+------------------------------+
3 rows in set (0.00 sec)
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11