又是一个学过但没有用过的,现在只记得SELECT * FROM TABLE1了
首先下载安装Mysql,安装时会设置root账号密码。
打开command
Enter password: ***********
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 27
Server version: 8.0.15 MySQL Community Server - GPL
Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
SHOW DATABASES
mysql> SHOW DATABASES;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sakila |
| sys |
| test1 |
| world |
+--------------------+
7 rows in set (0.11 sec)
CREATE DATABASE
mysql> CREATE DATABASE test
-> ;
Query OK, 1 row affected (0.20 sec)
mysql> SHOW DATABASES;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sakila |
| sys |
| test |
| test1 |
| world |
+--------------------+
8 rows in set (0.00 sec)
USE DATABASE
mysql> USE test;
Database changed
TABLE
mysql> CREATE TABLE lang(name VARCHAR(20), handle VARCHAR(20));
Query OK, 0 rows affected (0.63 sec)
mysql> DESCRIBE lang;
+--------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------+-------------+------+-----+---------+-------+
| name | varchar(20) | YES | | NULL | |
| handle | varchar(20) | YES | | NULL | |
+--------+-------------+------+-----+---------+-------+
2 rows in set (0.00 sec)
mysql> INSERT INTO lang VALUES('C','handle');
Query OK, 1 row affected (0.11 sec)
mysql> SELECT *
-> ;
ERROR 1096 (HY000): No tables used
mysql> SELECT * FROM lang;
+------+--------+
| name | handle |
+------+--------+
| C | handle |
+------+--------+
1 row in set (0.00 sec)
mysql> INSERT INTO lang VALUES('C++','familar'),('Python','familar'),('JAVA','know');
Query OK, 3 rows affected (0.13 sec)
Records: 3 Duplicates: 0 Warnings: 0
mysql> SELECT * FROM lang;
+--------+---------+
| name | handle |
+--------+---------+
| C | handle |
| C++ | familar |
| Python | familar |
| JAVA | know |
+--------+---------+
4 rows in set (0.00 sec)
Typical SELECT
mysql> SELECT name FROM lang;
+--------+
| name |
+--------+
| C |
| C++ |
| Python |
| JAVA |
+--------+
4 rows in set (0.00 sec)
mysql> SELECT * FROM lang WHERE name='C';
+------+--------+
| name | handle |
+------+--------+
| C | handle |
+------+--------+
1 row in set (0.00 sec)