PHP MySQL creates database
The database has one or more tables.
Create database
CREATEDATABASEstatement is used to create a database in MySQL.
Syntax
CREATEDATABASEdatabase_name
Category | Detailed explanation |
Basic syntax | create database database name; |
Example | create database liwenkai; |
Example description | Create a database, the name of the database is liwenkai |
In order for PHP to execute the above statement, we must use the mysql_query() function. This function is used to send a query or command to the MySQL connection.
Rules for creating a database:
1. Cannot be used with other databases Duplicate name, otherwise an error will occur.
2. The name can be composed of any letters, Arabic numerals, underscores (_), and "$". It can start with any of the above characters, but it cannot use numbers alone, otherwise it will be confused with the numerical value.
3. You cannot use the MYSQL keyword as the database name or table name.
4. By default, the database name under Windows is not sensitive. The opposite is true under Linux, so in order to facilitate database transplantation between platforms, it is recommended to use lowercase to define database names and table names.
Example
A database named "myDB" is created in the following example:
Program running result:
Database created successfully
Delete database
Note:
drop is Chinese and can be translated as falling down, not wanting anymore
database It is refers to the library
# 是 The name of the library refers Example
Program run results:
# [Remember] NoteContinuing Learning: After the database is deleted, all the following data will be deleted, so you must be careful and corresponding before deleting Backup.
- Course Recommendations
- Courseware download
-
IntermediateFront-end Vue3 actual combat [handwritten vue project]
2857 people are watching -
ElementaryAPIPOST tutorial [Popularization of technical concepts related to network communication]
1795 people are watching -
IntermediateIssue 22_Comprehensive actual combat
5521 people are watching -
ElementaryIssue 22_PHP Programming
5172 people are watching -
ElementaryIssue 22_Front-end development
8713 people are watching -
IntermediateBig data (MySQL) video tutorial full version
4525 people are watching -
ElementaryGo language tutorial-full of practical information and no nonsense
2794 people are watching -
ElementaryGO Language Core Programming Course
2814 people are watching -
IntermediateJS advanced and BootStrap learning
2563 people are watching -
IntermediateSQL optimization and troubleshooting (MySQL version)
3374 people are watching -
IntermediateRedis+MySQL database interview tutorial
2963 people are watching -
ElementaryDeliver food or learn programming?
5708 people are watching
Students who have watched this course are also learning
- Let's briefly talk about starting a business in PHP
- Quick introduction to web front-end development
- Large-scale practical Tianlongbabu development of Mini version MVC framework imitating the encyclopedia website of embarrassing things
- Getting Started with PHP Practical Development: PHP Quick Creation [Small Business Forum]
- Login verification and classic message board
- Computer network knowledge collection
- Quick Start Node.JS Full Version
- The front-end course that understands you best: HTML5/CSS3/ES6/NPM/Vue/...[Original]
- Write your own PHP MVC framework (40 chapters in depth/big details/must read for newbies to advance)
- About us Disclaimer Sitemap
- php.cn:Public welfare online PHP training,Help PHP learners grow quickly!
## Category | Detailed explanation |
drop database library name; | ## Example |
Example description | |
steer in the example below deletes a database called "MyDB": #Database deletion is successful |