Several MySQL statements commonly used in PHP _php tutorial

Source: Internet
Author: User
Several MySQL statements commonly used in PHP
To display a database or table:
Show databases;//can then use database_name;
Show tables;
Change table name:
ALTER TABLE table_name rename new_t;
To add a column:
ALTER TABLE table_name ADD column c_n column attributes;
To delete a column:
ALTER TABLE table_name DROP column c_n;
To create an index:
ALTER TABLE c_table Add index (C_N1,C_N2);
ALTER TABLE c_table add unique index_name (c_n);
ALTER TABLE c_table add primary key (SID);
To delete an index:
ALTER TABLE c_table DROP INDEX c_n1;
To change column information:
ALTER TABLE t_table change c_1 c_1 varchar (200);
ALTER TABLE t_table Modify 1 c_1 varchar (200);
Insert Insertion Statement:
INSERT INTO table_name (c_1,c_2)
Values (x1,1);
UPDATE statement:
UPDATE table_name set c_1 =1 where c_2=3;
To delete a database or table:
DROP TABLE table_name;
Drop database database_name;//can be deleted using mysql_drop_db ().

http://www.bkjia.com/PHPjc/486619.html www.bkjia.com true http://www.bkjia.com/PHPjc/486619.html techarticle several MySQL statements commonly used in PHP display the database or table: Show databases;//can then use database_name; Show tables; change table name: ALTER TABLE table_name rename n ew_t; Add Columns ...

  • 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.