用sql语句Mysql数据库的字段名?

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了用sql语句Mysql数据库的字段名?相关的知识,希望对你有一定的参考价值。

网上有很多,但是大部分都是错的。我想错的一个原因是大家互相抄袭,以讹传讹,嗨哟一个很大的原因是大家写的不标准。请回答时候尽量写标准些。
数据库类型: mysql
数据表名称: sheet1
原字段名:age char(10)
要修改成字段名:bir char(20)

请问怎么做?谢谢了,在线==
用sql语句修改mysql数据库字段名,当然不是删除后再建的那个,而是保留原数据,更新实现的方法。

SQL语言,数据库基础电子资料:

SQL语法大全中文版
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=148128
SQL语言案头完全参考手册
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=146159
SQL - A Practical Introduction
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=148095
O'Reilly SQL Tuning
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=159156
O'Reilly The Art of SQL
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=163611
数据库综合资料库
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=146238
数据库设计指南
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=148082
Wrox Beginning Database Design
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=145206
SQL Puzzles and Answers
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=160834
SQL Queries for Mere Mortals
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=162978
SQL Puzzles and Answers
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=160834
Apress出版 The Berkeley DB Book
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=168290
The Handbook of Data Mining
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=176600
数据库系统概论 浙江大学张军教授主讲(全32讲)
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=154299

MS SQL Server电子资料:

Transact-SQL Cookbook
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=163150
SQL Server 2005宝典
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=149644
Microsoft SQL Server 2005完全参考
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=152872
O'Reilly Learning SQL on SQL Server 2005
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=163464
Beginning SQL Server 2005 Programming
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=153216
Pro SQL Server 2005 High Availability
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=162981
Beginning SQL Server 2005 Administration
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=152863
SQL Server 2005 Management and Administration
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=176845
SQL Server 2005 Unleashed
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=152874
Pro SQL Server 2005
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=152325
A Developer's Guide to SQL Server 2005
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=145565
Pro T-SQL 2005 Programmer's Guide
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=154245
Beginning Transact-SQL with SQL Server 2000 and 2005
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=152868
SQL Server 2005报表服务
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=148376
Wrox Professional SQL Server 2005 Programming
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=151270
Scaling Out SQL Server 2005权威指南
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=162785
Sql Server 2005 Performance Optimiztion and Tuning Handbood
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=165048
Microsoft SQL Server 2005编程傻瓜书
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=152864
Pro SQL Server 2005 Assemblies
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=151269
MS SQL Server 2005 Reporting Essentials
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=147862
SQL Server 2005工具箱内幕
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=152321
SQL Server 2005管理员手册
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=152347
SQL Server 2005工具箱内幕
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=152321
SQL Server 2005数据挖掘
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=148099
Pro SQL Server 2005 Service Broker
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=159656
Pro SQL Server 2005 Replication
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=160606
Sql server 2005的XML最佳实施策略
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=152278
Microsoft SQL Server Black Book
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=163457
MS SQL Server2000 宝典
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=145853
SQL Server 2000存储过程和XML编程
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=152873
SQL Server 2005高级数据分析视频教程系列
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=162737
SQL Server 2005盛宴系列视频 全52讲
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=151642

MySQL电子资料:

MySQL宝典
http://bbs.topsage.com/dispbbs_122_159157_1.html
SQL for MySQL Developers
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=152862
MySQL教程
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=146824
Teach Yourself MySQL in 10 Minutes
http://bbs.topsage.com/dispbbs_122_174432_1.html
O'Reilly MySQL Pocket Reference 第二版 PDF
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=175014
MySQL 5 权威指南(第三版)
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=148867
MySQL培训经典教程
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=146795
MySQL Cookbook 第二版
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=175972
The Definitive Guide to MySQL
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=175382
O'Reilly MySQL Pocket Reference 第二版
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=175014
MySQL Essential Skills
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=146749
MySQL Administrators Guide
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=146580
MySQL权威指南 中文版+英文版
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=148870
MySQL 4.1.0 中文参考手册
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=148869
MySQL in a Nutshell
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=148868
Export MySQL
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=152865
MySQL and PHP from Scratch
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=152162
参考技术A alter sheef1 set age char(10) where bir char(20)
试试吧 不敢肯定 呵呵本回答被提问者采纳
参考技术B sql server2000下是这样的

exec sp_rename 'sheet1.age','bir', 'COLUMN'
然后再
alter table sheet1 alter colunm bir char(20)

我说的是微软的sql2000下的办法,至于mysql我不大清楚

mysql我想添加一个字段,然后将这个字段和原表中的字段一起作为联合主键,应该怎么写SQL语句,正确再发答案

添加字段的语句应该类似ALTER TABLE tbl ADD COLUMNS (字段名 数据类型...);
如果没有主键,那就可以ALTER TABLE tbl ADD PRIMARY KEY(....);
至于有的话,我也不太清楚了。

我本机没有数据库,上面的是凭印象写出来的,不对勿怪……
参考技术A ALTER TABLE 表名 ADD 字段名 类型( 长度 ) NOT NULL

ALTER TABLE 表名 DROP PRIMARY KEY ,
ADD PRIMARY KEY ( 字段名1 , 字段名2 )追问

这样如果原来表里的主键没有作为其它表的外键是可以,但是如果要DROP的主键又作为其它表的外键好像就不行了吧!

本回答被提问者采纳

以上是关于用sql语句Mysql数据库的字段名?的主要内容,如果未能解决你的问题,请参考以下文章

用mysql查询某字段是不是有索引怎么做?

用SQL语句查询出数据表中的字段名以及注释(Oracle)

如何用Sql语句添加字段?

MySQL数据库建库时SQL语句中数据库名表名用引号的问题以及COLLATE utf8_general_ci的含义

mysql数据库中sql修改字段类型要怎么做

怎样用SQL语句修改字段名