Home Database Mysql Tutorial mysql 表维护与改造代码分享

mysql 表维护与改造代码分享

Jun 07, 2016 pm 05:55 PM
mysql table maintain

当数据库中表的数量比较多时,不利于维护,本文将以此问题进行详细介绍如何维护mysql表,与如何修改mysql表

改变列的数据类型
[sql]
ALTER TABLE visitor MODIFY nam VARCHAR(30);
追加新列
[sql]
ALTER TABLE visitor ADD age INT;
ALTER TABLE visitor ADD age INT FIRST;
ALTER TABLE visitor ADD age INT AFTER nam;
改变列的位置
[sql]
ALTER TABLE visitor MODIFY age INT AFTER nam;
改变列名 和 类型
[sql]
ALTER TABLE visitor CHANGE birth birthday DATE;
删除列
[sql]
ALTER TABLE visitor DROP age;
表的复制
[sql]
CREATE TABLE customerH SELECT * FROM customer;
CREATE TABLE customerG LIKE customer;
INSERT INTO customerG SELECT * FROM customer;
INSERT INTO tb1G(no) SELECT bang FROM tb1;
表的删除
[sql]
DROP TABLE IF EXISTS customerG;
DROP TABLE customerG;
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to use Pagoda Panel for website repair and maintenance How to use Pagoda Panel for website repair and maintenance Jun 21, 2023 pm 03:19 PM

In the current Internet era, websites have become an important means for many companies to display and promote themselves. However, it is inevitable that some unexpected situations will cause the website to be inaccessible or have limited functions. At this time, the website needs to be repaired and maintained. This article will introduce how to use Pagoda Panel for website repair and maintenance. 1. Introduction to Pagoda Panel Pagoda Panel is a website management software running on a Linux server. It can help users quickly build a Web environment on the server operating system. The Pagoda panel integrates numerous functional modules

How to deploy and maintain a website using PHP How to deploy and maintain a website using PHP May 03, 2024 am 08:54 AM

To successfully deploy and maintain a PHP website, you need to perform the following steps: Select a web server (such as Apache or Nginx) Install PHP Create a database and connect PHP Upload code to the server Set up domain name and DNS Monitoring website maintenance steps include updating PHP and web servers, and backing up the website , monitor error logs and update content.

Write easy-to-maintain Golang stored procedures Write easy-to-maintain Golang stored procedures Feb 24, 2024 pm 08:27 PM

How to write maintainable stored procedures in Golang In Golang, if you want to write maintainable stored procedures, you first need to understand the concept of stored procedures and how to implement them in Golang. A stored procedure is a reusable block of code stored in a database that contains a series of SQL statements. Stored procedures simplify code, improve performance, and encapsulate business logic. This article will introduce how to write maintainable stored procedures in Golang and provide specific code examples. 1. Connect to the database first

MySQL table design tutorial: Create a simple user points table MySQL table design tutorial: Create a simple user points table Jul 02, 2023 am 10:12 AM

MySQL table design tutorial: Create a simple user points table Title: MySQL table design tutorial: Create a simple user points table Introduction: In developing common user systems, the points system is an important component. This article will teach you how to use MySQL to create a simple user points table, and comes with code examples to help you better understand and practice the table design. Text: Determine the name and fields of the table First, we need to determine the name of the table and the fields required in the table. For the user points table, we can name it

Optimizing PyCharm annotations: improving code maintainability Optimizing PyCharm annotations: improving code maintainability Feb 19, 2024 pm 07:37 PM

Comments play a vital role in the process of writing code. It not only helps other developers understand our code, but also makes it easier to review the code logic during future maintenance and optimization. As a powerful Python integrated development environment, PyCharm provides rich and practical annotation functions. This article will introduce how to use annotations rationally in PyCharm to make our code easier to maintain. 1. Single-line comments in Python, single-line comments start with "#", it can be

MySQL Table Design Guide: Creating a Simple User Message Table MySQL Table Design Guide: Creating a Simple User Message Table Jul 02, 2023 pm 12:04 PM

MySQL Table Design Guide: Create a Simple User Message Table When developing an application or website, it is often necessary to store messages or notifications between users. This article will guide you on how to create a simple user message table in a MySQL database to efficiently store and process messages between users. First, let's define the structure of our user messages table. Suppose our application has two user tables user1 and user2, and they can send messages to each other. We need a message table to store the messages between them. I

MySQL Table Design Guide: Create a Simple Article Image Table MySQL Table Design Guide: Create a Simple Article Image Table Jul 02, 2023 pm 07:13 PM

MySQL table design guide: Create a simple article picture table In our daily application development, we often need to store articles and related picture information. In the MySQL database, how to design a simple and efficient article picture table? This article will provide you with a reference solution and attach code examples. 1. Table structure design First, we create a table named "articles" to store article information, including the title, content and other fields of the article. At the same time, we also need to create a "name" field to represent

Code refactoring experience and suggestions in Java development Code refactoring experience and suggestions in Java development Nov 22, 2023 pm 08:12 PM

In Java development, code refactoring is a very important link. It can help us improve code quality, reduce code redundancy, and improve maintainability and performance. This article will share some experiences and suggestions on code refactoring, hoping to be helpful to Java developers. Determine the goals of refactoring Before refactoring code, you first need to clarify what the goals of refactoring are. Is it to improve code readability? Or is it to improve performance? Or is it to fix bugs? Clear goals can help us refactor in a more targeted manner instead of blindly making changes.

See all articles