This article brings you an introduction to common command operations in MySQL (code examples). It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.
l Create database: CREATE DATABASE table_name;
l Delete database: DROP DATABASE table_name;
l Show database: SHOW DATABASE;
l Select database: USE table_name;
Note: All database names, table names, and table names Field names are case-sensitive. So, we must use appropriate names before giving any SQL command.
l Create table: CREATE TABLE table_name (column_name column_type); //column column
l Delete table: DROP TABLE table_name;
l Rename table: ALTER TABLE table_name RENAME TO new name;
l Create instance:
create table table_tbl( table_id INT NOT NULL AUTO_INCREMENT, //AUTO~自动增加id字段下一个可用编号 table_title VARCHAR(100) NOT NULL, //字段使用NOT NULL属性,用户创建具 table_author VARCHAR(40) NOT NULL, 有NULL的记录会报错 submission_date DATE, PRIMARY KEY ( table_id ) //主关键字,一般分配后不再更改 );
l Insert data:
INSERT INTO table_name ( field1, field2,...fieldN ) VALUES ( value1, value2,...valueN ); //注意对应创建表时对列的定义
l Query display data:
SELECT field1, field2,...fieldN table_name1, table_name2... [WHERE Clause] [OFFSET M ][LIMIT N]
SELECT * from table_name; //返回所有记录 SELECT * from table_name WHERE table_author='wonker'; //返回作者是wonker的记录
l Modify data:
UPDATE table_name SET field1=new-value1, field2=new-value2 [WHERE Clause] UPDATE table_name SET table_title='Learning JAVA' WHERE table_id=3;
l Delete records:
DELETE FROM table_name [WHERE Clause] DELETE FROM table_tbl WHERE table_id=3;
l Delete, add or redefine columns: ALTER command
mysql view table structure command, as follows:
l desc Table name;
l show columns from table name;
l describe table name;
l show create table table name;
Due to the database table The additions, deletions, modifications and checks result in discontinuous numbers. You can use the following method to delete the number and then re-establish the number:
ALTER TABLE table_tbl DROP title_author; //删除 ALTER TABLE table_tbl ADD num INT; //添加 ALTER TABLE table_tbl ALTER num SET DEFAULT 1000; //更改默认值
create table if not exists table_name(---);
The above is the detailed content of Introduction to common command operations in MySQL (code examples). For more information, please follow other related articles on the PHP Chinese website!

本篇文章给大家带来了关于mysql的相关知识,其中主要介绍了关于架构原理的相关内容,MySQL Server架构自顶向下大致可以分网络连接层、服务层、存储引擎层和系统文件层,下面一起来看一下,希望对大家有帮助。

在mysql中,可以利用char()和REPLACE()函数来替换换行符;REPLACE()函数可以用新字符串替换列中的换行符,而换行符可使用“char(13)”来表示,语法为“replace(字段名,char(13),'新字符串') ”。

mysql的msi与zip版本的区别:1、zip包含的安装程序是一种主动安装,而msi包含的是被installer所用的安装文件以提交请求的方式安装;2、zip是一种数据压缩和文档存储的文件格式,msi是微软格式的安装包。

方法:1、利用right函数,语法为“update 表名 set 指定字段 = right(指定字段, length(指定字段)-1)...”;2、利用substring函数,语法为“select substring(指定字段,2)..”。

转换方法:1、利用cast函数,语法“select * from 表名 order by cast(字段名 as SIGNED)”;2、利用“select * from 表名 order by CONVERT(字段名,SIGNED)”语句。

本篇文章给大家带来了关于mysql的相关知识,其中主要介绍了关于MySQL复制技术的相关问题,包括了异步复制、半同步复制等等内容,下面一起来看一下,希望对大家有帮助。

本篇文章给大家带来了关于mysql的相关知识,其中主要介绍了mysql高级篇的一些问题,包括了索引是什么、索引底层实现等等问题,下面一起来看一下,希望对大家有帮助。

在mysql中,可以利用REGEXP运算符判断数据是否是数字类型,语法为“String REGEXP '[^0-9.]'”;该运算符是正则表达式的缩写,若数据字符中含有数字时,返回的结果是true,反之返回的结果是false。


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

SublimeText3 Linux new version
SublimeText3 Linux latest version

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

WebStorm Mac version
Useful JavaScript development tools

SublimeText3 English version
Recommended: Win version, supports code prompts!
