Mysql-related Common commands

Source: Internet
Author: User

1: A table has multiple primary keys.

Composite primary key

Create Table SC

(Studentno int, courseid int, score int, primary key (studentno, courseid ));

2: Use Chinese storage in the database

Create Database 'Article' default Character Set utf8 collate utf8_general_ci;

 

3: A good tutorial on SQL statements

Http://www.w3school.com.cn/ SQL/SQL _alter.asp

 

4. Modify Table content

Update class set c_year = "2011" where c_id = 1;

5. delete a row

Delete from test where t_id = "1 ";

6: Pretty good. MySQL functions commonly used in PHP

Http://www.php.net/manual/zh/ref.mysql.php

7. Set Foreign keys in the table

Create Table notice_ziliao (z_id varchar (20) primary key, z_date varchar (20), z_name varchar (128), z_t_id varchar (40), foreign key (z_t_id) references teacher (t_id ));

In the foreign key (z_t_id), do not add double quotation marks or quotation marks. Otherwise, a syntax error is returned.

 

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.