Investigation, increase, deletion and modification of database

Source: Internet
Author: User
Data | Database MySQL time is not long, the operation of the database is nothing more than the increase of records, find records delete records and modify records.
Summed up some of the following commands to share with you:
Connection command: mysql-h[host address]-u[user name]-p[user Password]
Creating databases: Create database [library name]
Display all databases: show databases;
Open database: Use [library name]
Currently selected library Status: Select Database ();
Creating a datasheet: Create table [table name] ([Field name] [Field type] ([Field requirements]) [Field parameters], ...);
Display data table fields: describe;
Current library datasheet structure: show tables;
Change table
ALTER table [table name] ADD COLUMN [field name] DATATYPE
Description: Adds a field (without deleting a field's syntax.)
ALTER table [table name] ADD PRIMARY KEY ([Field name])
Description: Change the definition of a table to set a field as the primary key.
ALTER table [table name] DROP PRIMARY KEY ([Field name])
Description: Delete the definition of the primary key.
Displays the current table field: Show columns from TableName;
Delete database: drop database [library name];
Delete table: drop table [table name];
Data manipulation
Add: INSERT into [table name] VALUES (', ' ",...... sequentially arranged data);
Query: SELECT * FROM [table name] WHERE ([condition]);
Index: CREATE index [index file name] on [table name] ([field name]);
Delete: delete from [table name] WHERE ([condition]);
Modify: UPDATE [table name] SET [modify content such as name = ' Mary '] WHERE [condition];

Import External Data text:
1. Execute an external SQL script
Execution on current database: MySQL < input.sql
Specify execution on database: MySQL [table name] < Input.sql
2. Data incoming command load infile "[filename]" into table [table name];
Back up the database: (Dos)
Mysqldump--opt SCHOOL&GT;SCHOOL.BBB



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.