Home > Database > Mysql Tutorial > body text

How to display, delete, modify and select databases in MySQL

WBOY
Release: 2023-06-01 09:25:11
forward
670 people have browsed it

 1. Delete database

mysql> drop database  stu;
Copy after login

 If the deleted database does not exist, an error will be reported. The solution is to judge before deleting and delete it if it exists

 mysql> drop database if exists stu;
  Query OK, 0 rows affected (0.00 sec)
Copy after login

 2. Display the statement to create the database

Syntax: show create database database name

 mysql> show create database yudb;
Copy after login

  ---------- --------------------- -----------------------------------------------

| Database | Create Database

  ---------- -------------------------------- -------------------------------

| yudb | CREATE DATABASE `yudb` /*!40100 DEFAULT CHARACTER SET gbk */

  ------------------------------------------ -------------------------------

 3. Modify database character encoding

 Syntax: alter database database name charset=character encoding;

    mysql> alter database yudb charset=utf8;
  Query OK, 1 row affected (0.00 sec)
Copy after login

 4. Select database

Syntax: use database name

  mysql> use yudb;
  Database changed
Copy after login

The above is the detailed content of How to display, delete, modify and select databases in MySQL. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template