Create database
Category | Detailed explanation |
---|
Basic syntax | CREATE DATABASE database name; |
##Example | CREATE DATABASE PHP; |
Example description | Create a database, the name of the database is PHP |
Example:
mysql> CREATE DATABASE PHP;
Query OK, 1 row affected (0.00 sec)
"Query OK" means the above command is executed successfully. "Query OK" is displayed after all DDL and DML (excluding SELECT) operations are executed successfully. , here it is understood that the execution is successful; "1 row affected" means that the operation only affects the records of one row in the database, and "0.00 sec" records the time when the operation was executed.
If this database already exists, the system will display:
mysql> CREATE DATABASE PHP;
ERROR 1007 (HY000): Can't create database 'PHP'; database exists
View database
Basic syntax:
Category | Detailed explanation |
Basic syntax | show databases; |
Example description | Display all databases of the current server |
Note:
show refers to display
Database refers to the database
databases is the plural form of database, referring to all databases.
Example:
mysql> SHOW DATABASES;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| user |
+--------------------+
4 rows in set (0.00 sec)
Selected database
Basic syntax:
##Category Detailed explanation | |
Basic syntax | use library name; | # #Example
use PHP | | Example description
Use database PHP | # # Note: use refers to use; The library name is the name of the specific database that exists in the current database system; Example: mysql> use PHP;
Database changed
This will enter the PHP database. Of course, you can use the use statement to switch the database to be operated at any time. PHP has just been selected. Now let’s switch to the mysql database with mysql content and take a look: mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
If "Database changed" appears, the switch is successful. Then, see what is in the mysql database (use the show statement the same as viewing the current database server database) View the tables in the databaseAfter entering the library, we can see what is in the library How many data tables. Category | Detailed explanation |
---|
Basic syntax | show tables; | Example description | Show all tables under the current database |
After using use to enter a database, you can use show tables Example to view the tables of the current database: mysql> show tables;
+--------------------------+
| Tables_in_mysql |
+--------------------------+
| columns_priv |
|db
| event
| func
| general_log |
| help_category |
| help_keyword |
| help_relation |
| help_topic |
| innodb_index_stats |
| innodb_table_stats |
| ndb_binlog_index |
| plugin |
| proc |
| procs_priv |
| proxies_priv |
| servers |
| slave_master_info |
| slave_relay_log_info |
| slave_worker_info |
| slow_log |
| tables_priv |
| time_zone |
| time_zone_leap_second |
| time_zone_name |
| time_zone_transition |
| time_zone_transition_type |
| user
+--------------------------+
28 rows in set (0.00 sec)
The content in these tables is information data related to users, permissions, database status, settings, etc. related to the relational database server.
Delete databaseCategory | Detailed explanation |
---|
Basic syntax | DROP DATABASE library name; | Example | DROP DATABASE PHP; | Example description | Delete a database, the name of the database is liwenkai |
Note: drop is in Chinese Translated to mean falling down, no longer needed database refers to the library The library name refers to the name of the library to be deleted Example: mysql> DROP DATABASE PHP;
Query OK, 0 rows affected (0.01 sec)
【Remember】Note: After the database is deleted, all data below will be deleted, so be careful and make appropriate backups before deleting. (If important data is not backed up, the actual data risk has nothing to do with this book.) Next Section<?php
echo "Hello Mysql";
?> - Chapter1Why choose this course to learn PHP
- Why learn PHP?
- What is PHP
- You can learn even with z...
- Why can't some people lea...
- Chapter2PHP environment installation
- What is the development e...
- Windows environment insta...
- Linux environment install...
- Other development environ...
- Tool selection for writin...
- Chapter3php basic syntax
- PHP basic syntax
- Our first piece of PHP co...
- Variables in php - you wi...
- echo display command
- Learning php annotations
- Data types are not myster...
- PHP integer type is an in...
- PHP data type Boolean (ac...
- PHP data type string
- PHP data type floating po...
- PHP flow control if else ...
- PHP data type NULL type
- php data type array
- Resource type of php data...
- PHP data type viewing and...
- Automatic conversion and ...
- Object (will learn later)
- PHP constants and variabl...
- PHP constants and variabl...
- PHP constants and variabl...
- PHP constants and variabl...
- Variable references for P...
- PHP basic syntax arithmet...
- PHP basic syntax assignme...
- PHP basic syntax: self-in...
- PHP basic syntax comparis...
- Logical operations of php...
- PHP basic syntax bit oper...
- PHP basic syntax: ternary...
- Chapter4PHP process control
- Process control in PHP
- PHP process control if co...
- PHP flow control if state...
- Nested if...else...elseif...
- Multiple nesting of if st...
- Use of branch structure s...
- Use of loop statements in...
- while loop
- The difference between do...
- PHP flow control for loop...
- PHP flow control goto syn...
- Chapter5Basic function syntax of PHP
- Basic function syntax of ...
- PHP function basic syntax...
- PHP custom function callb...
- PHP custom function varia...
- PHP custom function anony...
- Internal function of php ...
- Variable scope of php cus...
- Reference to parameters o...
- PHP custom function recur...
- Static variables of php c...
- php uses system built-in ...
- php file contains functio...
- PHP math commonly used fu...
- PHP function to obtain pe...
- php date validation funct...
- PHP gets localized timest...
- PHP program execution tim...
- PHP string common functio...
- Chapter6PHP arrays and data structures
- PHP arrays and data struc...
- php array definition
- PHP array calculation
- php for loop traverses in...
- php foreach traverses as...
- PHP list, each function t...
- PHP commonly used array m...
- Common functions for php ...
- Chapter7Regular expressions in PHP
- Regular expressions in PH...
- Delimiter expressed by ph...
- Atoms in php regular expr...
- Metacharacters in php reg...
- Pattern modifiers in php ...
- Tips and commonly used re...
- PHP uses regular expressi...
- Chapter8php file system
- File system
- php read file
- php creates and modifies ...
- php creates temporary fil...
- php move, copy and delete...
- php detect file attribute...
- Common functions and cons...
- php file locking mechanis...
- php directory processing ...
- php file permission setti...
- php file path function
- PHP implements file guest...
- PHP implementation exampl...
- Chapter9PHP file upload
- PHP file upload
- When uploading files, you...
- Steps to upload php files
- Precautions for php file ...
- php completes file upload...
- php multiple file upload
- PHP file upload progress ...
- Chapter10PHP image processing
- PHP image processing
- PHP image processing gd2 ...
- PHP uses image processing...
- PHP development verificat...
- php image scaling and cro...
- PHP image watermark proce...
- Chapter11PHP error handling
- Error handling
- PHP error handling prohib...
- PHP error handling error ...
- PHP error handling error ...
- PHP error handling custom...
- Chapter12Getting started with MySQL
- Getting Started with MySQ...
- Mysql database introducti...
- Mysql entertainment expla...
- mysql database installati...
- Data statement operation ...
- Mysql connect to database
- Mysql database operation
- Mysql data table operatio...
- Mysql data field operatio...
- Mysql data type
- Mysql character set
- Mysql table engine
- Mysql index
- Mysql add, delete, modify...
- Mysql add, delete, modify...
- Mysql multi-table joint q...
- Mysql addition, deletion,...
- Mysql add, delete, modify...
- DCL statement
- Learn commonly used Engli...
- Chapter13PHP operates mysql database
- PHP operates mysql databa...
- PHP database connection s...
- PHP operates the database...
- PHP database operation: m...
- PHP database operation: p...
- PHP database operation: b...
- PHP database operation to...
- The ultimate solution to ...
- Chapter14php session management and control
- session overview
- Overview of Cookies for P...
- php session control Cooki...
- PHP session control using...
- php SESSION application e...
- Session management and co...
- Chapter15Making a thief program through cURL
- php curl usage methods an...
- php curl custom get metho...
- php curl uses post to sen...
- Making a thief program th...
- Chapter16Learn commonly used English words in PHP
- List of commonly used Eng...
|