Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use storage structure in MySQL

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

In this issue, the editor will bring you about how to use the storage structure in MySQL. The article is rich in content and analyzes and narrates it from a professional point of view. I hope you can get something after reading this article.

1. Create two new data tables: student1 and student2

Create a new student1

DROP TABLE IF EXISTS student1;CREATE TABLE student1 (id INT NOT NULL auto_increment,name TEXT,age INT,PRIMARY KEY (id))

Create a new student2

DROP TABLE IF EXISTS student2;CREATE TABLE student2 (id INT NOT NULL auto_increment,name TEXT,age INT,PRIMARY KEY (id))

two。 Add data to student1

INSERT INTO student1 (name, age) VALUES ('xiaoming', 18); INSERT INTO student1 (name, age) VALUES (' xiaohong', 17); INSERT INTO student1 (name, age) VALUES ('xiaogang', 19); INSERT INTO student1 (name, age) VALUES (' xiaoyu', 18); INSERT INTO student1 (name, age) VALUES ('xiaohua', 20)

Implementation function description

1. Print some of the information in student1

two。 Copy part of the data from student1 to student2

3. Pass in parameters as restrictions to copy part of the data in student1 to student2

Matters needing attention

When writing a storage structure, we cannot end with a semicolon (;). Because our SQL statement ends with a semicolon (;). Here we want to modify the closing symbol (& &) of the storage structure.

Here we use DELIMITER in MySQL to modify it and change it to a semicolon (;) when the storage structure is created.

This is reflected in later examples. A similar situation is used in writing triggers for MySQL.

Mode of use

1. Print some of the information in student1

-DROP PROCEDURE IF EXISTS test_pro1 -DELIMITER & & CREATE PROCEDURE test_pro1 () BEGIN set @ sentence = 'select * from student1 where age

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.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report