zoukankan      html  css  js  c++  java
  • MYSQL 第三章 基操

    基本操作增删改查

    mysql> show databases;    #查看databases   记住后面要加s
    +--------------------+
    | Database           |
    +--------------------+
    | information_schema |
    | employees          |
    | mysql              |
    | performance_schema |
    | sys                |
    | test               |
    | test_db_char       |
    +--------------------+
    7 rows in set (0.00 sec)
    
    mysql> show database like 'te%';
    ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'database like 'te%'' at line 1
    mysql> show databases like 'te%';    #使用 like 关键字进行模糊匹配查询  '%te%' , 'te%' , '%te'
    +----------------+
    | Database (te%) |
    +----------------+
    | test           |
    | test_db_char   |
    +----------------+
    2 rows in set (0.00 sec)
    
    
    mysql> show create database test;   #查看已经创建的  database 的信息 ,不需要加s 
    +----------+--------------------------------------------------------------------------------+
    | Database | Create Database                                                                |
    +----------+--------------------------------------------------------------------------------+
    | test     | CREATE DATABASE `test` /*!40100 DEFAULT CHARACTER SET utf8 COLLATE utf8_bin */ |
    +----------+--------------------------------------------------------------------------------+
    1 row in set (0.00 sec)
    
    mysql> create database user_zy;      #create  关键字创建数据库
    Query OK, 1 row affected (0.00 sec)
    
    mysql> show create database user_zy;   #查看信息
    +----------+--------------------------------------------------------------------+
    | Database | Create Database                                                    |
    +----------+--------------------------------------------------------------------+
    | user_zy  | CREATE DATABASE `user_zy` /*!40100 DEFAULT CHARACTER SET latin1 */ |
    +----------+--------------------------------------------------------------------+
    1 row in set (0.00 sec)
    
    mysql> show databases;
    +--------------------+
    | Database           |
    +--------------------+
    | information_schema |
    | employees          |
    | mysql              |
    | performance_schema |
    | sys                |
    | test               |
    | test_db_char       |
    | user_zy            |
    +--------------------+
    8 rows in set (0.00 sec)
    
    mysql> alter database user_zy default character set utf8;   #alter 关键字修改数据库信息
    Query OK, 1 row affected (0.00 sec)
    
    mysql> show create database user_zy;
    +----------+------------------------------------------------------------------+
    | Database | Create Database                                                  |
    +----------+------------------------------------------------------------------+
    | user_zy  | CREATE DATABASE `user_zy` /*!40100 DEFAULT CHARACTER SET utf8 */ |
    +----------+------------------------------------------------------------------+
    1 row in set (0.00 sec)
    
    mysql> drop database if exists user_zy;
    Query OK, 0 rows affected (0.01 sec)
    
    

     mysql> use user_zy;   #use 关键字选择数据库
     Database changed
     mysql>




    帮助:

    mysql> help contents;    #查询帮助文档列表
    You asked for help about help category: "Contents"
    For more information, type 'help <item>', where <item> is one of the following
    categories:
       Account Management
       Administration
       Compound Statements
       Contents
       Data Definition
       Data Manipulation
       Data Types
       Functions
       Geographic Features
       Help Metadata
       Language Structure
       Plugins
       Procedures
       Storage Engines
       Table Maintenance
       Transactions
       User-Defined Functions
       Utility
    
    mysql> help 'Account Management';  #查询指定信息
    
    You asked for help about help category: "Account Management"
    For more information, type 'help <item>', where <item> is one of the following
    topics:
       ALTER USER
       CREATE USER
       DROP USER
       GRANT
       RENAME USER
       REVOKE
       SET PASSWORD
    
    mysql> 
  • 相关阅读:
    VirtualBox安装
    记一次修改fstab挂载参数
    Debian其实有提供附带了各种桌面的安装镜像
    记一次使用unzip命令
    记一次给iPhone 6越狱
    浅谈.Net中内置的一种特殊的引用类型 -- String类型
    .Net中的静态类和非静态类、静态成员和非静态成员
    .Net子窗体给父窗体传值的几种方法
    int、float、double In .Net之相互转换
    车厢重组
  • 原文地址:https://www.cnblogs.com/zy09/p/12973877.html
Copyright © 2011-2022 走看看