PHP Basics: Database meaning and basic operations additions and deletions

Source: Internet
Author: User
Tags php basics

A database is a software that helps us manage our data, and we give it to him and put it in the database. He can help us manage it very well and efficiently.
Most of PHP's work is to display the data---formatted data--data-------Php-> connected database,
Database management data is formed in the form of a table, multiple rows and columns, a table header declaration, a table is created, and the rest is to add data to the table in a folder inside the form of a library MySQL server to help us manage multiple libraries C:\wamp\bin\mysql\ The data in the Mysql5.6.12\data database is placed in this file. MyD is the data file database is to store our data into a file, the management of a penny class,
CMD Client connection mysql:mysql-h localhost-u root-p root
View Gallery show databases;
Select library: Use blog;
View the table below the gallery: show tables;
Query table Data select * from blog;


Database additions and deletions change
Add Data: Note that columns and values must be strictly corresponding numbers can be quoted, but also to int to understand but the string must be quoted, no quotation marks will be interpreted as a variable, or a column name will be an error
1 Add all columns insert into blog (uid,name,age,) VALUES (1, ' Zhansnag ', 18);
2. A row has a lot of content and columns we can also add only a subset of columns insert INTO blog (uid,name) VALUES (1, ' Lisi ');
3. Primary key can not write the primary key from Add column insert into blog (name,age) VALUES (' Wangwu ', 55);
4. Add more than one row of data at a time: INSERT into blog values (1. ') Zhangsan ', 9), (2. ') Lisi ', (+), (3, ' Wangwu ', ' 25 '); Add multiple rows of data at once to separate them with commas
//

Update modification
Format Update table name set column 1 = new value, column 2 = new value where qualification. such as: Update blog set name= ' Xiaogui ' where uid=2;
Data is very valuable, be sure to add where condition, without the Where condition all the database files will be modified,


Delete Deletes
Deleting only one column in the middle of a row is an update operation. For a traditional database, a row is its atomic unit add is a row, delete is also a row,
Format: Delete from table name where qualification, such as delete from blog where uid=1;
Be sure to add the where condition, without the Where condition will delete the data.


Select query
Format: Select column 1, column 2, column 3 where qualification
1. Query all rows of the table for all columns select * from blog; In development, try not to write as much as the data in the table, so that the query will add to the burden of the server, need a few data, just a few good
2. Query a row: SELECT * from blog where uid=1;
3. Querying multiple lines: SELECT * from blog where uid>=2;
4. Query a few rows of a few columns * represents all columns: Select Uid,name,age from blog where uid=2;

PHP Basics: Database meaning and basic operations additions and deletions

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.