美文网首页
初探mysql

初探mysql

作者: ustclcl | 来源:发表于2019-03-02 22:21 被阅读0次

又是一个学过但没有用过的,现在只记得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)

相关文章

  • 初探 MySQL

    启动与停止MySQL服务 在cmd界面中启动与停止mysql服务: net start mysql net sto...

  • 初探MySQL

    语法规则: SQL不区分大小写,通常做法是用大写编写所有SQL命令。 在SQL中,会忽略空格和换行。 一个SQL语...

  • 初探mysql

    又是一个学过但没有用过的,现在只记得SELECT * FROM TABLE1了 首先下载安装Mysql,安装时会设...

  • python bugs

    操作mysql数据库报错Incorrect string value Django之TIME_ZONE初探 关于P...

  • MySQL事务初探

    笔者在使用mysql的时候,经常困惑于是否应该使用事务以及是否应该使用select...for update。于是...

  • MySQL锁初探

    本文的示例代码参考laravel-lock 目录 MySQL ProjectComposerMigrationSe...

  • MySQL事务初探

    事务是MySQL等关系型数据库区别于NoSQL的重要方面,是保证数据一致性的重要手段。 事务ACID四大特性 原子...

  • Mysql用户表初探

    问题: Access denied for user 'root'@'localhost' (using pass...

  • 初探 MySQL 的 Binlog

    原文地址:https://xcoder.in/2015/08/10/mysql-binlog-try/ 花瓣网的搜...

  • MySql调优初探

    1.查询MySql系统变量:SHOW VARIABLES LIKE '%quer%'; 2.查询慢查询数量: SH...

网友评论

      本文标题:初探mysql

      本文链接:https://www.haomeiwen.com/subject/vhzyuqtx.html