SQL First Lesson Notes

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.