"Python" Database Exercise-1

Source: Internet
Author: User
Tags flush

34 Database

1. View Database Commands

2. Use a database

3. See which library is currently in

4. See which tables are in the current database

5. querying data in a table

6. Build Library: Create database testbase;

7. Build tables: CREATE TABLE user (id int not null);

CREATE table with Name user_wangjing, field Id,date1,date2, etc.

New table name, meaning int 11 bits in parentheses, cannot be empty

8. Insert data: INSERT INTO user values (1);

9. to view information for a table:

10. Delete a table

11. Delete Library: drop database testbase;

12. New User:

Create user ' student11 ' @ '% ' identified by ' gloryroad ';

FLUSH privileges;

% indicates that all IPs can be logged in, ' student11 ' @ ' 10.60.89.% ' means that only the IP of this field can be logged in

13. Change Password:

UPDATE USER SET password=password (' 12345622xw1 ') WHERE user= ' GG1 ';

FLUSH privileges;

14. Create users and Modify permissions for users

Grant all privileges the Test.user to [e-mail protected] "%" identified by "Gloryroad"; # Let the user have permission to manipulate any database

Flush privileges;

15. build table, insert value

ENGINE=INNODB Storage database with InnoDB engine, if you want to use foreign keys, transactions and other functions, you need to InnoDB engine

16. to view the fields and properties of a table: show columns from book_wangjing;

17. View index: Show index from book_wangjing;

18. View 2 data, the first two from the beginning do not look, print then the back of the

19. See article 2 of 3

20. query table data and OR:

21. an alias to a field in a table

22. sorting fields in a table

SELECT * from book where Book_author like '% teacher ';

To calculate the number of data bars in a table:

Calculate Average:

"Python" Database Exercise-1

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.