First, three ways to open MySQL server
1, open through Windows Management mode
2. Open via DOS command line
3, directly using the mysqld in the bin directory to complete
Second, login MySQL client
General Continuation Input: Set names gbk;--client character set is GBK;
Set default database: Use database name;
Third, the MySQL annotation character
1, single-line comment:
#
--Comment on the content, note that there is a space between the comment and the content!
2, multi-line Comment:
/* Comment content */
Iv. ddl:data definition Language, data definition language
It is primarily used to define and maintain the various operands of the database, such as libraries, tables, indexes, views
It can also be said that the level of operation is in the database and the logical structure of the table and the storage structure above, and does not operate the actual data in the table (increased deletion)!
Key operating keywords are: Create, drop, alter, etc.
1. Database operation
Create DATABASE: "CREATE DATABASE [if not EXISTS] database name [db option];
See which databases are currently available: show databases;
View the creation statement for the database: show create database name;
Delete database: Drop database [if exists] name;
Modify database: ALTER DATABASE name new library option;
2. Data table operation
Create a data table under the default database: (If the CREATE table [if notexists] database is created under a different database. Table name (field type ...) Table option information;)
View table: Show tables;
Show tables like "character _%"; Wildcard: _ can represent any single character,% can represent any character!
Show create table table name;
Delete Table: Table name of drop table [if exists] ;
Modify Table name Syntax:
1)
2)
3) In addition, we can also use rename syntax to implement the data table movement:
Modify table options: ALTER TABLE table name option information;
3. Modify the column definition
Add a column: ALTER TABLE name add field name fields type;
Delete a column: ALTER TABLE name drop field name;
Modify field type: ALTER TABLE table name modify field name new field type;
To modify a field sort:
1)
2)
To rename a field:
Modify Table Options:
V. Dml:data manipulation Language, data manipulation language
The main is the record in the table for the operation of the increase and deletion check!
The operation of the data is also known as CRUD:
C:create Increase
R:read Search
U:update Change
D:delete Delete
Among them, "Query" section, can be called as Dql:data query Language, data query Language! Keywords: select
Insert data:
1) The field list here can be all or part of the field (that is, insert only part of the data, others default to null, meaning nothing)
2) The field list and the value list should be one by one, and the order in the field list can be different from the order in the table, but it must be the same as the order after the list of values.
3) when inserting data for all fields, the list of fields can be omitted, and the list of values must correspond to the order one by one in the datasheet!
4) You can also insert a lot of data at a time, separated by commas!
Query data:
1) When querying all fields, you can use * instead of
2) query conditions can be omitted, the default is to query all records, equivalent to where 1;
Delete data:
Here the deletion conditions are often not omitted, if omitted, the default is to delete all the records in the table!
To modify the data:
and delete the data, the modification conditions here are also often necessary!
Database MySQL Basics 1