_php Tutorial of database search, increment, delete and change

Source: Internet
Author: User
Learn MySQL time is not long, the database operation is nothing more than add 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]
Show all databases: show databases;
Open database: Use [library name]
Current Selected Library Status: Select Database ();
Create data table: Creation table [table name] ([Field name] [Field type] ([field requirement]) [Field parameter], ...);
Display data table field: describe name;
Current Library data table structure: show tables;
Change a table
ALTER table [table name] ADD COLUMN [field name] DATATYPE
Description: Adds a field (no syntax for deleting a field).
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: Deletes the definition of the primary key.
Displays the current table field: Show columns from TableName;
Delete library: drop database [library name];
Delete tables: 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]);
Modified: UPDATE [table name] SET [modify content such as name = ' Mary '] WHERE [condition];
Import External Data text:
1. Execute the external SQL script
Executing on current database: MySQL < input.sql
Execution on the specified database: MySQL [table name] < Input.sql
2. Data incoming commands load data local infile "[file name]" into table [table name];
Backing Up the database: (Dos)
Mysqldump--opt SCHOOL&GT;SCHOOL.BBB

http://www.bkjia.com/PHPjc/631193.html www.bkjia.com true http://www.bkjia.com/PHPjc/631193.html techarticle Learn MySQL time is not long, the database operation is nothing more than add records, find records delete records and modify records. Summed up some of the following commands to share with you: Connect command: Mys ...

  • Related Article

    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.