A review of some knowledge points in the database

Source: Internet
Author: User

1. Some knowledge points

The Mysql.exe path (D:\program files\wamp\bin\mysql\mysql5.5.20\bin) can be added to the environment variable path in the system properties of the computer so that MySQL can be used in any directory. For example: input the MySQL system in CMD can be identified;

A database is made up of many tables, and you can use keys as a reference between tables.

2. Some of the commands and their use

A) Create the database: creation databases Suyd;

b) View the database that exists in the system: show databases;

c) Switch the database, the default current operation in this library: use Suyd;

d) View the tables that exist in the database suyd: show tables;

e) Creating tables: Create table users (ID int not NULL auto_increment primary key, username char (+) NOT null default ', PASSW Ord varchar (+) NOT null default ", age int. NOT NULL default 0, sex char (4) is not null default", email varchar (+) not Nu ll default "); (there is a point in quotation marks) '

f) View the created table: show tables;

g) View table users ' specific structure: desc users;

h) View the statement creating Table users: show create table users;

i) operation of the table

    Insert : INSERT into users (IDs, username, password, age, sex, email) VALUES (' 1 ', ' suyd ', ' 123456 ', ' A ', ' Girl ', ' [email Protected] ');

Query table information for users: SELECT * from users;

    modified : Update users set username = ' Su ' where id = 2;

Modify multiple values at the same time: Update users set age = n, sex = ' girl ';

Modify multiple values for a person at the same time: Update users set age = 1, sex = ' girl ' where-id = +;

Delete : Delete from users where id = 1;

Enquiry

Querying the table for all cases: SELECT * from users;

Query the case of an item in the table: Select ID, username from users;

To query the condition of an item in a table according to a requirement:

Select ID, username, age+10 as age10 from users;

Select ID, username, age from the users where age > 10;

j) Delete the entire table or library:

drop table users;

Drop database Suyd;

A review of some knowledge points in the database

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.