First day, MySQL installation, DDL (database definition Language), DBA,DML (Database manipulation language), import SQL file outside

Source: Internet
Author: User
Tags dba mysql download

Add "D:\mysql-5.6.22-winx64\bin" to the system environment variable path, and then in any directory can access MySQL and other commands, such as login and other operations do not need to enter the MySQL installation directory to perform!

MySQL Download (two):
Website: www.oracle.com
1) Download MySQL Community Server (GPL)---mysql database
2) MySQL Connectors---JDBC driver

Login: Mysql-u root-p1234

See which databases are available: show databases;
Open a database: use database name;
See which tables are in the Open database: show tables;

Dba:
Create a new User: Creation user Hncu identified by ' 1234 ';
Authorization to User: Grant all on * * to ' hncu ' @ '% ' with GRANT option;
※※※※ Note that after you create a new user, you can close and restart the MySQL server before it takes effect!

Common database Products: SQL Server, Oracle, MySQL

SQL language is not case sensitive


DDL (data definition language, Language)
Build libraries, build tables, set constraints, and more: Create\drop\alter

1. Create a database:
Create DATABASE IF not EXISTS hncu CHARACTER SET UTF8;

2. Create a table:
Use Hncu;
CREATE TABLE IF not EXISTS stud (
ID int,
Name varchar (30),
Age int
);

3. Change the table structure (set constraints)
DESC Stud; View table Structure
ALTER TABLE stud drop column age;
ALTER TABLE stud add column age int;

4. Delete a table, delete a database
drop table stud;
Drop database Hncu;


Ii. DML (Data manipulation language, manipulation Language)
Mainly refers to the deletion and modification of data: Select\delete\update\insert\call

SELECT * FROM stud;
Select Name,age from Stud; Querying the specified column
Select name as name, age as ages from stud;
※※ Remember: Table fields (field, table header) must be in English, if you want to display as a Chinese table header, with an alias to solve.


INSERT into stud values (2, ' Zhang San ', 22);
INSERT INTO stud (id,age) values (4,23); Specifies the assignment of field names, which is more efficient
Delete from stud where id=4;
Update stud set age = age+1; The age of all students plus 1


Import Script code
SOURCE D:\a\1.sql

CMD path
C:\Windows\System32

First day, MySQL installation, DDL (database definition Language), DBA,DML (Database manipulation language), import SQL file outside

Related Article

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.