In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Xiaobian to share with you the use of mysql database methods, I believe most people do not know how to share this article for your reference, I hope you have a lot of harvest after reading this article, let us go to understand it together!
Start and close MySQL Server
Start MySQL Server
Start-> Run Enter "cmd" and then enter the command "net start MySQL" at the command prompt.
2. Connect to MySQL Server
Input command: MySQL -uroot -h227.0.0.1 -p111 (-h227.0.0.1 depends on personal situation)
Note: The username is "root", the MySQL database server address is "127.0.0.1", and the password is "111". There must be a space between the three.
Close MySQL Server
Start-> Run Enter "cmd" and then enter "net stop MySQL" command at the command prompt.
2. Operating MySQL Database
1. Create a database
create database name;
2. View the database
show databases;
3. Select the specified database
use database name;
4. Delete database
drop database name;
Note: Automatically deletes the "C: /AppServ/MySQL/data" folder in the MySQL installation directory.
III. Operation MySQL Data Table
1. Create a table
create table name (column_name column_type not null,...);
Description of attributes of create table statement
attribute
description
attribute
description
column_name
field name
Primary key
Is this column a primary key?
column_type
field type
AUTO_INCREMNT
Is this column automatically numbered
Not null | null
Whether this column is allowed to be empty
After creating the data table, the corresponding table file (Table Name.frm, Table Name.MYD, Table Name.MYI) is automatically created in C: \AppServ\MySQL\data\Database Name\.
2. View tables in the database
show tables;
View all tables in the database
show tables;(if using the use database;)
4. View data table structure
describe table name;
5. Modify the data table structure
alter table name add [column] create_definition [first| after column_name] //add new field add primary key (index_col_name,...) //add primary name alter [column] col_name {set default literal| drop default} //Modify field name change [column] old_col_name create_definition //Modify field name and type modify [column] create_definition //Modify field type drop [column] col_name //Delete field drop primary key //Delete primary code rename [as] new_tablename //Change table name eg: alter table Admin_Info drop A_Pwd, rename as Admin_Info2;
6. Delete the specified data table
drop table name;
4. Operating MySQL Data
1. Add table data
Syntax 1: insert into table name values (value 1, value 2,...) Syntax 2: insert into table name (field 1, field 2,...) values (value 1, value 2,...) Syntax 3: insert into table name set Field 1= value 1, Field 2= value 2,...
2. Update table data
update table name set field 1= value 1 where query condition
If there is no query condition, all data rows in the table will be modified.
3. Delete table data
delete from table name where query criteria
If there is no query condition, all data rows in the table will be deleted.
4. Query table data
select * from table name;
5. Limit the number of query records
select * from table name limit[start] length
start: indicates which line the output starts from, 0 indicates the first line
The above is the use of mysql database method of all content, thank you for reading! I believe that everyone has a certain understanding, hope to share the content to help everyone, if you still want to learn more knowledge, welcome to pay attention to the industry information channel!
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.