Kinds of data types
Shaping: can have decimal and hexadecimal representations
Fu: Floating-point numbers consist of a number plus a decimal point plus a number. Two number sequences cannot be empty at the same time.
String: A character or number enclosed in single or double quotes that is a special symbol in the string to be represented by an escape character.
Date and time value: Lieru 2005-05-30 12:30:25 Date is by year-month-day
Nuul value: is an untyped value that means "empty, nothing."
________________________________________________________________________________
MYSQL-H host name-u username-p password//mysql login Run command
DML Data Manipulation language
Select query Select field name, Field name, ... (*) from table name WHERE clause
Query Select field name, Field name, ... (*) from table name WHERE clause unit Price 500 limit 3 Top 3
Select *from Kehu,yewuyuan where ye_id=ke_id query the ID of the salesperson's account
Insert into Badwolf (Bad_id,bad_name) VALUES (3, ' Badbird '); Insert
Update Modify update Badwolf (table name) set bad_name (column name) = ' Badwolf ';
Updata Badwolf (table name) set bad_name column name = ' Alex ' value where bad_name= ' Badbird ';
Delete Deletes from Badwolf (indicates) where bad_id=2;
DCL Data Control Language
Grant Controls access permission
Revoke access rights
DDL Data Definition Language
Create table creates a datasheet creation table library name;
drop table Database Object
ALTER TABLE defines its columns
When MySQL enters the end of a statement, it must have a number at the end. -> meaning this statement does not lose the wait to continue typing. \c is used to cancel the input.
/////////////////////////////////////////////////////////////////////////
Numeric type
Tinytin very small integers BIGINT large integers
SMALLINT small integer Float floating-point number
Mediumint medium sized integer double double double-precision floating-point number
INT Standard integer DECIMAL floating-point number of a string
CHAR fixed-length string varchar variable long string
Tinyblob very small blob blob small blob
Mediumblob medium Bolb Longblob Large blob
Tinytext very small text string text small text string
Mediumtext medium Text Longtext Large text string
Enum enumeration: Columns can be assigned to an enumeration member
Set collection: Columns can be assigned to more than one collection member
Auto_increment Automatic identity column
The column you want to use this property should be defined as not NULL and defined as primary key or defined as a unique key.
Unsigned unsigned, this property disables negative values by starting the range of values from zero, that is, the value range is moved forward.
///////////////////////////////////////////////////////////////////////////////////
Creating a Database
Create database library name; Create a database with the specified name
For example: Create DATABASE book; A database named book was created
Show database lists the databases available in the server
Show table shows the list of databases
Use a database for example using a library name:
Not NULL non-null PRIMARY key primary key auto_increment self increase
Common integrity constraints
Primary key main code constraint (primary key) main code is the primary key, can uniquely mark the field properties
Unique UNIQUE constraint in a field or a group of fields the data is unique compared to the data in other rows in the table
NOT NULL Non-empty value constraint
Auto_increment Integer Series 1
Default_value Default Value Constraint
Show structure actions
database table name
DESC Table Name
Delete a database or table operation
drop TABLE table name delete Table drop table if exists Badbird add if exists delete table name does not exist error
Drop database name Delete Library ditto plus if exists no error
////////////////////////////////////////////////////////////
Change Table structure actions
Syntax: ALTER TABLE name action;
Description: Action can be the following statement:
Add column name < CREATE TABLE statement > [i | after column name]
Add primary key (column name) adds a primary key to the table and an error occurs if the primary key already exists
ALTER COLUMN name set default defaults to change the default value of the specified column
----------------------------------------------------------
Later table name add Insert as column name varchar (property) first (before) |after (after) Add column name
Change old column name new column name < table statement > [i | after column name]
You can change the column type and the column name, and if the original column has the same name as the new column, the changes and modify act the same
-----------------------------------------------------------
Modify Column name < table statement > [i | after column name]
Change column properties: ALTER TABLE badbird (table name) badtitle (column) modif varchar (properties);
Changing column name: ALTER TABLE Badbird (table name) change badtitle (column) Bad_sad (changed name) varchar (property) NOT NULL (no null);
Drop Column name//can delete a column
Drop PRIMARY key//can delete primary key
Drop index index_name; You can delete an index
Delete column: ALTER TABLE badbird (table name) drop Badtitle;
Rename as new table name//can change the table name
Change table name: ALTER TABLE Badbird (table name) Rename Badwolf (table name);
Insert Record action
Grammar:
Insert into table name (field name, field name, ...) VALUES (field value, field value,...);
For example: INSERT INTO Badwolf (Bad_id,bad_name) VALUES (3, ' Badbird '); Insert
If the table name is not followed by a field name, the default is to add a value to all fields, and the string value should be enclosed in "or" quotes
Multiple additions: INSERT into Badwolf values (1, ' Badbird '), (2, ' Badbird '), (4, ' Badbird ');
Change the record operation
Grammar:
Update table name set column name = data value WHERE clause;
For example: Update Badwolf (table name) set bad_name (column name) = ' Badwolf ';
------------------------------------------------------------------
The WHERE clause is a judgment statement that is used to set conditions, restrict updates to only matching rows, and update all row data without a WHERE clause
Delete Record operation syntax: delete from table name WHERE clause;
For example: Delete from Badwolf (indicates) where bad_id=2; To determine the value of deleting all id=2 criteria can be attached
Current 1/2 page
12 Next read the full text