Re-learning MySQL data sheet (ii)

Source: Internet
Author: User

< Create data tables >

1. Null and non-empty
null field can be NULL NOT NULL cannot be empty
2.auto_increment
AutoNumber , must be used with primary key, by default, starting value is 1, each increment is 1
3.PRIMARY KEY
PRIMARY KEY constraint, there is only one primary key in each data table, the primary key guarantees the uniqueness of the record, and the primary key is automatically not NULL "is not necessarily used with auto_increment"
4.QUIQUE KEY
Unique constraints, UNIQUE constraints guarantee the uniqueness of a record, a field with a unique constraint can be a null value [NULL], multiple UNIQUE constraints can exist for each data table
5.DEFAULT
Default value, which is automatically assigned to the default value when the record is inserted without explicitly assigning a value to the field
CREATE TABLE [IF not EXISTS] table_name (
field FirstName Property [not NULL] auto_increment PRIMARY KEY,
field FirstName Property [not NULL] UNIQUE KEY,
Field FirstName Property Default ' defaults ',
)
</Creating data Tables >

< summary >


</Summary >

< constraints >


</Constraints >


< foreign KEY Constraints >


</FOREIGN KEY Constraint >

< referential actions for foreign KEY constraints >

</FOREIGN KEY constraint the reference Operation >

< table-level constraints and column-level constraints >

</
table-level constraints and column-level constraints >

< View data Table list >
SHOW TABLES [FORM db_name] [like ' DSAS ' | WHERE EXPT];
</View data Sheet list >

< View data sheet information >
Show CREATE DATABASE tablename;
</View data sheet information >

< View data sheet structure >
show columns from table_name;
</View data table structure >

< inserting records >
insert [INTO] table_name (field name, Field Name 2, Field 3 ...) VALUES (' Val1 ', ' val2 ', ' val3 ' ...);
</inserting records >

< find records >
Select {Field name | *} from tablename;
</Find Records >

Re-learning MySQL data sheet (ii)

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.