In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
The following talk about mysql database what basic operation command, the secret of the text is close to the theme related. So, gossip will not talk about it, we look directly at the following bar, I believe that after reading the mysql database which basic operation command this article you will certainly benefit.
I. Mysql Basic Operation Command:
(1) View database list information:
show databases;
(2) Check the data table information in the database:
use database name; //view database show tables; //View Data Sheet
(3) Display the structure of the data table (fields):
describe database name;
II. SQL statement overview:
(a) SQL language:
Structured Query Language; a standard language for relational databases; used to maintain and manage databases, such as data queries, data updates, access control, object management, etc.
(b) SQL classification:
DDL: Data Definition Language;DML: Data Manipulation Language;DQL: Data Query Language;DCL: Data Control Language;
(1) DDL operation command:
DDL statements are used to create database objects, such as libraries, tables, indexes, etc.
1. Creation:
create database name; //create database create table table name (field definition...) //Create a data table
For example, the following creates an info table containing ID number, grade, name and address:
Primary key: identifies the unique entity object in the table. It is unique and non-empty (both must be satisfied).
mysql> use team; //Enter Database changed mysql> create table info( //create a table named info -> id int(4) not null, -> name char(10) not null, -> address varchar(50) default 'Beijing', //default is default -> score decimal, -> primary key (id)); //ID as primary key
Remarks:
General use char type storage fixed data such as ID number (18) telephone number gender…
Varchar for variable data
float: floating point type, containing 4 bytes, 32 bits, the value range is-3.4E38~3.4E38 (7 significant bits)
double: double precision real type, including 8 bytes, 64bit value range-1.7E308~1.7E308 (15 significant bits)
decimal: numeric, 128bit, no loss of precision, often used in bank account calculations. (28 significant bits)
2. Delete:
drop table [database name.] table name //delete the specified database drop database name //Delete the specified database
(2) DML operation command:
DML statements are used to manage data in tables, including the following operations:
insert: insert new data;update: update existing data;delete: delete unwanted data;
1. Insert
insert into table name (field 1, field 2...) values (value of field 1, value of field 2...)
For example, based on the previous table, let's do the following insertion:
mysql> insert into info (id,name,address,score) values (001,'zhangsan','Shanghai', 99);//insert a message named zhangsan, id 1, Shanghai, score 99 mysql> insert into info (id,name,address,score) values (002,'lisi',' Hangzhou', 88);//insert a message named lisi, id 2, Hangzhou, score 88 mysql> insert into info (id,name,address,score) values (003,'wangwu', default,77);//Insert a message named zhaowu, id number 3, Nanjing, score 77
2, modify, update (update)
update table name set field name 1= value 1 where conditional expression
For example, the following table adds an address to jack:
Enter the following command:
update info set address='Wuhan' where name='jack';
3, delete (delete)
delete from table name where conditional expression detele from table name //Delete the entire table
(3) DQL operation command:
Used to find qualified data records from the data table. No condition can be specified when querying.
Command: Select
1. No conditions specified:
select field 1 from table name
2. Specify condition query:
select field 1 from table name where conditional expression
(4) DCL operation command:
1. Set user permissions (if the user does not exist, create a new user):
GRANT Permission List ON Database Name. Table Name TO User Name @ Source Address [ IDENTIFIED BY 'Password']
2. View user permissions:
SHOW GRANTS FOR Username @ Source Address
3. Revoke the user's rights:
REVOKE Permission List ON Database Name. Table Name FROM User Name @ Source Address
For the above mysql database what are the basic operation command related content, what do you still do not understand? Or if you want to know more about it, you can continue to pay attention to our industry information section.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.