Start: Touch MySQL,: Touch MySQL

Source: Internet
Author: User
Tags mysql command line web database

Start: Touch MySQL,: Touch MySQL

To learn about MySQL, you must install a MySQL database. It must be simple to install. In fact, I downloaded MySQL5.7 and Baidu completed the installation step. It is much simpler than Oracle.

I bought two books and read MySQL, which is suitable for beginners. The following part of the learning process will be referred to in this book. Although there are many e-books on the internet, paper books are always better. Start.

1. Database Basics

A database is actually a table. A table is divided into rows and columns. A database can have multiple tables, each of which records a type of information. For example, a table records students' scores, A table records the teacher's courses. It would be strange to put the student scores and the teacher's courses in a table. Each column in the table must have a type value, such as numbers, text, and length. The attributes of these tables are called schema. It is emphasized that each row in the table must have a unique id, which is mainly used for subsequent search and modification operations.

I also mentioned the SQL language, which is easy to understand because I have a basic C language. SQL, the language used to operate the database. Chapter 1 looks easier.

2. Environment

The environment is relatively simple. The website corresponding to this book provides SQL scripts to create suppliers, product directories, customer lists, and customer order lists. Download the script file. In the windows Start column, run MySQL Command Line Client. Enter the password to enter the MySQL command line.

A. create a database named lab: myslq> create database lab;

B. use the database: mysql> use lab;

C. Execute the downloaded script to create a table: mysql> source G: \ study \ MySQL \ mysql_scripts \ create. SQL;

D. Run the script to insert the following values: mysql> source G: \ study \ MySQL \ mysql_scripts \ populate. SQL.

E. view the content in the vendors table: myslq> select * from vendors;



Usage of stored procedures, triggers, and views in mysql

Create a stored procedure

Create procedure, Create function

Below are their formats:
Create proceduresp_Name ([proc_parameter])
Routine_body

Here, the parameter type can be in out inoutt, which means the same as the word, and IN indicates the passed parameter,
"OUT" indicates the outgoing parameters, and "INOUT" indicates the parameters passed in but finally returned.
Create functionsp_Name ([func_parameter])
Returns type

Routine_body
The Returns type specifies the returned type. The given type is the same as the returned type. Otherwise, an error is returned.

The following are two simple examples:

1. display the current Mysql version

Execution result
Mysql> use welefen;
Database changed
Mysql> delimiter // # define // as the end mark
Mysql> create procedure getversion (out param1 varchar (50) # param1 is the outgoing Parameter
-> Begin
-> Select version () into param1; # assign version information to param1
-> End
-> //
Query OK, 0 rows affected (0.00 sec)

Mysql> call getversion (@ a); # call the getversion () Stored Procedure
-> //
Query OK, 0 rows affected (0.00 sec)

Mysql> select @;
-> //
+ -------------------------- +
| @ A |
+ -------------------------- +
| 5.1.14-beta-community-nt |
+ -------------------------- +
1 row in set (0.00 sec)

2. display "hello world"

Execution result
Mysql> delimiter //
Mysql> create function display (w varchar (20) returns varchar (50)
-> Begin
-> Return concat ('hello', w );
-> End
... The remaining full text>

I just got in touch with mysql. I am not very familiar with the graphic interface management software of mysql. Could you please advise?

No, just do it. mysql's graphic management is a graphical program that calls the mysql Command. In this way, you do not need to back the command, and the graphic interface looks more comfortable. If you are using a windows system, I personally recommend the HeidiSQL software. Although it is not a Chinese language, the operations in it basically do not require any English. It is a graphic interface, which is simple. You can also use phpMyAdmin, a php-based Web database management software that supports Chinese characters.

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.