This is the note I re-wrote after I read the IMOOC video tutorial.
Although I've learned about SQL Server databases before, I've also forgotten about them. Now pick it up again, install a database exercise, and use MySQL.
The first lesson is the simplest to create, modify, view, and delete databases;
MySQL has the password after the command line landing with Shell>mysql-u Root-p;
Prompt to enter password:
After the login is successful, change the prompt to MySQL to the current computer account name @ Host name current database format: Prompt \[email protected]\h \d>
Several basic parameters under the prompt command \d the current date; \d current database; \u current user; \h current host name;
Create a database
Creation {database | SCHEMA} [IF not EXISTS] db_name [DEFAULT] CHARACTER SET [=] charset_name;
| The vertical bar represents either side of the selection, [] the brackets represent optional, writable, and
if not EXISTS refers to the creation of a warning if it exists, and
CHARACTER SET is used to specify the character encoding, such as Gbk,utf8;
Example: CREATE DATABASE t1; Create a database named T1
For example: Create DB if not EXISTS T1;//If it does not exist, creates a warning if it exists; View warning: show warnings;
Example: CREATE DATABASE T2 CHARACTER SET=GBK; Create a T2 database with an encoding format of GBK
: show create Database T2;
See how many databases are in the current database management system
SHOW {DATABASES | SCHEMAS} [like ' Pattern ' | WHERE Expr]
Example: SHOW DATABASES;
Modify Database
ALTER {DATABASE | SCHEMA} [Db_name] [DEFAULT] CHARACTER SET [=] charset_name;
The following article is a way to modify the encoding of a database
Example: ALTER DATABASE t2 CHARACTER SET = UTF8;
Deleting a database
DROP {DATABASE | SCHEMA} [IF EXISTS] db_name;
Example: DROP DATABASE t1;
If you execute the drop database T1 again, an error will occur, plus the keyword will execute successfully, resulting in a warning, such as the drop database if EXISTS t1;
View warning : Show warnings;
Review review:
Default port number for MySQL: 3306
MySQL has a super User: root
Creating databases: Create Database
modifying databases: ALTER DATABASE
Delete database: Drop db
If the commands for the database management system are to be distinguished from the other identifiers, try to capitalize them.
SQL First Lesson Notes