首页 > 数据库 >mysqlalter语句

mysqlalter语句

时间:2022-10-27 12:36:39浏览次数:31  
标签:mysqlalter 语句 name index alter ... col help

mysql中alter语句中change和modify的区别
您可以使用CHANGEold_col_namecolumn_definition子句对列进行重命名。重命名时,需给定旧的和新的列名称和列当前的类型。例如:要把一个INTEGER列的名称从a变更到b,您需要如下操作:·mysql>ALTERTABLEt1CHANGE
本回答由提问者推荐
mysql查看alter的用法
mysql里面的man功能使用help命令,你可以输入下面的命令:
helpalter
helpaltertable
help命令显示使用帮助的几本方法:
mysql>help
ForinformationaboutMySQLproductsandservices,visit:
Fordeveloperinformation,includingtheMySQLReferenceManual,visit:
TobuyMySQLNetworkSupport,training,orotherproducts,visit:
ListofallMySQLcommands:
Notethatalltextcommandsmustbefirstonlineandendwith';'
?(\?)Synonymfor`help'.
clear(\c)Clearcommand.
connect(\r)Reconnecttotheserver.Optionalargumentsaredbandhost.
delimiter(\d)Setstatementdelimiter.NOTE:Takestherestofthelineasnew
delimiter.
ego(\G)Sendcommandtomysqlserver,displayresultvertically.
exit(\q)Exitmysql.Sameasquit.
go(\g)Sendcommandtomysqlserver.
help(\h)Displaythishelp.
notee(\t)Don'twriteintooutfile.
print(\p)Printcurrentcommand.
prompt(\R)Changeyourmysqlprompt.
quit(\q)Quitmysql.
rehash(\#)Rebuildcompletionhash.
source(\.)ExecuteanSQLscriptfile.Takesafilenameasanargument.
status(\s)Getstatusinformationfromtheserver.
tee(\T)Setoutfile[to_outfile].Appendeverythingintogivenoutfile.
use(\u)Useanotherdatabase.Takesdatabasenameasargument.
charset(\C)Switchtoanothercharset.Mightbeneededforprocessingbinlog
withmulti-bytecharsets.
warnings(\W)Showwarningsaftereverystatement.
nowarning(\w)Don'tshowwarningsaftereverystatement.
Forserversidehelp,type'helpcontents'
helpalter命令查看alter的几本功能
mysql>helpalter
Manyhelpitemsforyourrequestexist.
Tomakeamorespecificrequest,pleasetype'help

',

where

isoneofthefollowing

topics:
ALTERDATABASE
ALTERPROCEDURE
ALTERTABLE
ALTERVIEW
GRANT
SPATIAL
helpaltertable查看altertable的详细解释
mysql>helpaltertable
Name:'ALTERTABLE'
Description:
Syntax:
ALTER[IGNORE]TABLEtbl_name
alter_specification[,alter_specification]...
alter_specification:
table_option...
|ADD[COLUMN]col_namecolumn_definition[FIRST|AFTERcol_name]
|ADD[COLUMN](col_namecolumn_definition,...)
|ADD{INDEX|KEY}[index_name][index_type](index_col_name,...)
|ADD[CONSTRAINT[symbol]]
PRIMARYKEY[index_type](index_col_name,...)
|ADD[CONSTRAINT[symbol]]
UNIQUE[INDEX|KEY][index_name][index_type](index_col_name,...)
|ADD[FULLTEXT|SPATIAL][INDEX|KEY][index_name](index_col_name,...)
|ADD[CONSTRAINT[symbol]]
FOREIGNKEY[index_name](index_col_name,...)
reference_definition
|ALTER[COLUMN]col_name{SETDEFAULTliteral|DROPDEFAULT}
|CHANGE[COLUMN]old_col_namenew_col_namecolumn_definition
[FIRST|AFTERcol_name]
|MODIFY[COLUMN]col_namecolumn_definition[FIRST|AFTERcol_name]
|DROP[COLUMN]col_name
|DROPPRIMARYKEY
|DROP{INDEX|KEY}index_name
|DROPFOREIGNKEYfk_symbol
|DISABLEKEYS
|ENABLEKEYS
|RENAME[TO]new_tbl_name
|ORDERBYcol_name[,col_name]...
|CONVERTTOCHARACTERSETcharset_name[COLLATEcollation_name]
|[DEFAULT]CHARACTERSETcharset_name[COLLATEcollation_name]
|DISCARDTABLESPACE
|IMPORTTABLESPACE
index_col_name:
col_name[(length)][ASC|DESC]
index_type:
USING{BTREE|HASH|RTREE}
ALTERTABLEenablesyoutochangethestructureofanexistingtable.
Forexample,youcanaddordeletecolumns,createordestroyindexes,
changethetypeofexistingcolumns,orrenamecolumnsorthetable
itself.Youcanalsochangethecommentforthetableandtypeofthe
table.
doc/refman/5.0/en/alter-table.html
mysql查看alter的用法
mysql里面的man功能使用help命令,你可以输入下面的命令:
help alter
help alter table
help命令显示使用帮助的几本方法:
mysql> help
For information about MySQL products and services, visit:
For developer information, including the MySQL Reference Manual, visit:
To buy MySQL Network Support, training, or other products, visit:
List of all MySQL commands:
Note that all text commands must be first on line and end with ';'
?(\?) Synonym for `help'.
clear(\c) Clear command.
connect(\r) Reconnect to the server. Optional arguments are db and host.
delimiter (\d) Set statement delimiter. NOTE: Takes the rest of the line as new
delimiter.
ego(\G) Send command to mysql server, display result vertically.
exit(\q) Exit mysql. Same as quit.
go(\g) Send command to mysql server.
help(\h) Display this help.
notee(\t) Don't write into outfile.
print(\p) Print current command.
prompt(\R) Change your mysql prompt.
quit(\q) Quit mysql.
rehash(\#) Rebuild completion hash.
source(\.) Execute an SQL script file. Takes a file name as an argument.
status(\s) Get status information from the server.
tee(\T) Set outfile [to_outfile]. Append everything into given outfile.
use(\u) Use another database. Takes database name as argument.
charset(\C) Switch to another charset. Might be needed for processing binlog
with multi-byte charsets.
warnings (\W) Show warnings after every statement.
nowarning (\w) Don't show warnings after every statement.
For server side help, type 'help contents'
help alter命令查看alter的几本功能
mysql> help alter
Many help items for your request exist.
To make a more specific request, please type 'help

',

where

is one of the following

topics:
ALTER DATABASE
ALTER PROCEDURE
ALTER TABLE
ALTER VIEW
GRANT
SPATIAL
help alter table查看alter table的详细解释
mysql> help alter table
Name: 'ALTER TABLE'
Description:
Syntax:
ALTER [IGNORE] TABLE tbl_name
alter_specification [, alter_specification] ...
alter_specification:
table_option ...
| ADD [COLUMN] col_name column_definition [FIRST | AFTER col_name ]
| ADD [COLUMN] (col_name column_definition,...)
| ADD {INDEX|KEY} [index_name] [index_type] (index_col_name,...)
| ADD [CONSTRAINT [symbol]]
PRIMARY KEY [index_type] (index_col_name,...)
| ADD [CONSTRAINT [symbol]]
UNIQUE [INDEX|KEY] [index_name] [index_type] (index_col_name,...)
| ADD [FULLTEXT|SPATIAL] [INDEX|KEY] [index_name] (index_col_name,...)
| ADD [CONSTRAINT [symbol]]
FOREIGN KEY [index_name] (index_col_name,...)
reference_definition
| ALTER [COLUMN] col_name {SET DEFAULT literal | DROP DEFAULT}
| CHANGE [COLUMN] old_col_name new_col_name column_definition
[FIRST|AFTER col_name]
| MODIFY [COLUMN] col_name column_definition [FIRST | AFTER col_name]
| DROP [COLUMN] col_name
| DROP PRIMARY KEY
| DROP {INDEX|KEY} index_name
| DROP FOREIGN KEY fk_symbol
| DISABLE KEYS
| ENABLE KEYS
| RENAME [TO] new_tbl_name
| ORDER BY col_name [, col_name] ...
| CONVERT TO CHARACTER SET charset_name [COLLATE collation_name]
| [DEFAULT] CHARACTER SET charset_name [COLLATE collation_name]
| DISCARD TABLESPACE
| IMPORT TABLESPACE
index_col_name:
col_name [(length)] [ASC | DESC]
index_type:
USING {BTREE | HASH | RTREE}
ALTER TABLE enables you to change the structure of an existing table.
For example, you can add or delete columns, create or destroy indexes,
change the type of existing columns, or rename columns or the table
itself. You can also change the comment for the table and type of the
table.
URL: table authors
constraint upkcl_auidind primary key clustered (au_id)
数据库中alter是什么意思?
通过更改、添加或删除列和约束,重新分配分区,或者启用或禁用约束和触发器,从而修改表的定义。简单说就是修改表结构的。
CREATE TABLE doc_exa ( column_a INT) ;
ALTER TABLE doc_exa ADD column_b VARCHAR(20) NULL ;

标签:mysqlalter,语句,name,index,alter,...,col,help
From: https://blog.51cto.com/yetaotao/5800734

相关文章

  • mysqlgroupby语句使用总结
    mysql怎么把groupgroupby语法可以根据给定数据列的每个成员对查询结果进行分组统计,最终得到一个分组汇总表。SELECT子句中的列名必须为分组列或列函数。列函数对于GROUPBY子......
  • python for-break-else 语句
    有两种情况可能会导致for循环结束。第一个是for循环中满足条件遇到break,第二种情况是循环自然结束。现在我们可能想知道其中的哪一个是循环完成的原因,一种方法是设置一个......
  • 今天独立尝试了增删改查,重点练习了修改语句
    效果还可以  查询语句出了点小问题   修改用到了4个jsp文件跳转其中session.setAttribute()语句的使用,刚开始由于理解上面的混乱,没有成功修改,后来才发现问题......
  • 工作中常用的SQL语句
    1.SQL篇1.根据一个spbh字段分组,然后取分组后每个spbh的created最新值select*from(select*fromt_userhaving1ORDERBYcreateddesc)aGROUPBYs......
  • switch 分支语句的应用
    switch常用于多分支语句,用法为:switch(整形表达式){case语句(整形常量表达式);}下面我们使用代码来助于大家理解。#include<stdio.h>#include<string.h>int main(){int day=0......
  • wireshark 过滤语句集合
    wireshark抓包软件,日常排障必备。一般在linux、mac下抓包,命令行的。经常会用tcpdump来抓包而windows使用wireshark来抓包,免费,好用。通常安装好wireshark后,直接指定网卡......
  • java输出(java输出语句快捷键)
    java最简单的输入输出java输出语句怎么写去百度文库,查看完整内容>内容来自用户:白岸海歌System.out.print——标准输出流Java的流类,主要是:输入流类InputStream输出流类Outp......
  • java输出语句(java输出语句格式+a,+什么意思)
    JAVA输入输出的用法?你是说控制台输入输出的问题吧代码如下:publicstaticvoidmain(String[]arg){Scannerscanner=newScanner(System.in);System.out.print("请输入......
  • 用SQL语句,删除掉重复项只保留一条
    在几千条记录里,存在着些相同的记录,如何能用SQL语句,删除掉重复的呢1、查找表中多余的重复记录,重复记录是根据单个字段(peopleId)来判断select*frompeoplewherepeopl......
  • efcore 连接SqlServer2008R2报错:'OFFSET' 附近有语法错误。 在 FETCH 语句中选项 NEXT
    用的是EFCore6,连接SqlServer2008R2时,生成的分页方法会报错,只需要指定ProviderName时加上版本号就行:Microsoft.EntityFrameworkCore.SqlServer@2008,高于2008版本就按默......