MySQL increases the basic content of the reduced library, table, data

Source: Internet
Author: User


Input command Note:
1 command ending sign semicolon;
2 All the symbols are English half-width
3 only if you encounter a semicolon MySQL will think of the end
4 multiple commands separated by semicolons
Viewing order: 1 View data show databases=>2 Enter database use library name =>3 view all tables show tables=>4select *from table name
View data commands
show databases;

Create a database
Create database name;

Deleting a database
drop database name;

Enter database and build table
Use library name;

View all the tables
Show tables;

Create a table field name data type constraint
Constraint: PRIMARY key: Primary key
Non-empty: NOT NULL
Defaults: Default value
To create a table note:
1 field must have field name and data type
2 multiple fields separated by commas
3 last field do not use commas
Create syntax
CREATE TABLE Table name (
Sno varchar (primary key),
sname varchar (default "Lao Wang"),
Ssex Int (10)

); Chestnuts as follows 6 field names
CREATE TABLE Teacher (
TNO varchar (primary key),
Tname varchar (default "faculty name"),
Tsex varchar (20),
Tbirthday varchar (20),
Prof varchar (20),
Depare varchar (20)
);
Delete a table
DROP table Name
View table Structure
DESC table name;

Data deletion and modification:
Add: INSERT into Table name values (value)
Translation: Which table (which column) value is added to (value 1, value 2, value 3 ...) Chestnuts are as follows: Full field input, separated by commas for each line of content
INSERT into student values ("108", "Zeng Hua", "male", "1977-09-01", "95033"),
("105", "Box Ming", "Male", "1975-10-02", "95031"),
("107", "Wang Li", "female", "1976-01-23", "95033"),
("101", "Li June", "male", "1976-02-20", "95033"),
("109", "Wang Fang", "female", "1975-02-10", "95031"),
("103", "Contacts", "Male", "1974-06-03", "95033");
Add full field can save token name (column)
Modify: Modify which table sets which field = value
Update table name set field 1= value 1, field 2= value 2, ... ;
Delete: Delete from which table
Delect from table name

MySQL increases the basic content of the reduced library, table, data

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.