Common database operation statements (1)

Source: Internet
Author: User

Build Library
CREATE DATABASE IF not EXISTS gloryroad DEFAULT CHARSET UTF8 COLLATE
Utf8_general_ci;
Build table
CREATE TABLE Studentinfo (
ID int NOT NULL auto_increment comment "non-nullable self-growing primary key ID",
student_id varchar () NOT NULL,
Name varchar (+) is not NULL,
Sex char (4),
Tel varchar (+) unique NOT NULL,
admissiondate datetime default ' 0000:00:00 00:00:00 ',
Primary KEY (ID),
Unique student_id (student_id)
) Engine=innodb Character Set UTF8 comment "Student information sheet";

See which databases are available
Show DATABASES

Choose to use that database
Use Python
See what database tables are available
Show TABLES
Deleting a database
Drop TABLE Demo;

Create a database user
Create USER ' hhq ' @ '% ' identified by "123456";
% can specify IP, only the person with the specified IP can connect to this database

Update the value of a table field
Update USER set Password=password (' 11111 ') where user= ' hhq1 '
Assigning Permissions to users
GRANT all privileges in . to [email protected] '% ' identified by ' 123456 '
Flush privileges;

Use Python;
SELECT database (); View the current library
View current Connected Users
SELECT user ();

Common database operation statements (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.