MySQL Basic operation

Source: Internet
Author: User

1. Create a database

Create database test; 2. CREATE TABLE student (id int, name char (8), sex char (4));-Create a student table with ID name sex three field 3. View data table fields select columns from student;  show CREATE TABLE student;d Escribe student; Columns where table_name= ' table name '; All of the above methods are available. 4. Insert the data into the insert [into] table name [(column name 1, column name 2, column name 3, ...)] VALUES (value 1, value 2, value 3, ...); The data within [] can omit insert student values (1, ' Luyg ', ' Girl '), insert the specified data into the Insert student (Id,name) VALUES (' Kobe '), 5. Updated Data Update table name set column name = new value where update condition; 6. Delete the data delete from table name where delete condition; Delete from Test where id = 1;  7. Modify the basic form of the table structure: ALTER TABLE name add column list data type [after insertion position]; Example: Append column at the end of the table Address:alter table students add address char (60), insert column after column named Age birthday:alter table students add birthday Date after age;8. Modify column basic form: ALTER TABLE name change column name New Name column new data type; example: Renaming a table Tel column to Telphone:alter table students Change Tel Telphone char (d) Efault "-"; Change the data type of the Name column to char (+): ALTER TABLE students changed name name Char (+) not null;9. Delete Column basic form: ALTER TABLE name DROP column name; ALTER TABLE test drop NAME10. Rename table basic form: ALTER TABLE name rename a new name; 11. Delete Table Basic form: drop database name;

MySQL Basic operation

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.