Basic mysql operations in Windows and basic windowsmysql

Source: Internet
Author: User

Basic mysql operations in Windows and basic windowsmysql

1. Database Table operations:

  • -Start the mysql server, open the cmd window in the directory where mysql is installed, and run mysql: 'mysql.exe-hlocalhost-p3306-uroot-p123456 ';
  • -View all databases: show databases; -- create database my_database;
  • -Use my_database; --> show tables; --> create table class (name varchar (10), room varchar (10) charset utf8; --> show tables like "% s "; -->
  • Query the table creation statement: show create table my_student; --> omit the colon statement: show create table my_student \ g --> another output format:
  • Show create table my_student \ G
  • -Rename the table: rename table student to my_student;
  • -View the table structure of the data table: desc table name; --> describe table name; --> show columns from table name;
  • -Add a new field to the table: alter table my_student add column id int first/after;
  • -Modify a field: it is usually an attribute or data type. --> alter table name mondify field name data type [attribute] [location]; --> alter table my_student modify number char (10) after id;
  • -Rename field: alter table name change old field new field data type [attribute] [location];
  • Alter table my_student change gender sex varchar (10) after id;
  • -Delete field: Delete the age field (age) in the student table --> alter table my_student drop age;
  • -- Delete a data table: drop table 1, 2, 3... --> drop table class;

2. Data Operations

  • Insert into my_student values (1, '001', 'J', 'jin'), (2. '002', 'h', 'huni ');
  • Insert into my_student (number, name, sex, id) values ('003 ', 'jeny', 'male', 3), ('004', 'the shy ', 'femal', 4 );
  • View data: select */Field List from table name [where condition]; --> select * from my_student; --> select id, number, sex, name from my_student where id = 1;
  • Update Data: update table name set field = value [where condition];
  • Delete data: delete form table name [where condition];

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.