100字范文,内容丰富有趣,生活中的好帮手!
100字范文 > sql alter table语句用法

sql alter table语句用法

时间:2018-08-10 03:47:15

相关推荐

sql alter table语句用法

数据库|mysql教程

sql alter,alter语句

数据库-mysql教程

易语言cpu优化源码,aidlux vscode配置,ubuntu 10.10,eclipse自带tomcat,sqlite是本地数据库,深圳网页设计好找吗,php网站如何导入数据库,最便宜的香港服务器,js 中国地图插件,avalon前端框架,常见爬虫,php 接口调用,SEO优化快速排名,好用的springboot组件,dede模板标签arclist实现分页,pc端网站转换手机站,手机网页图片轮播,discuz3 2模板,dedecms 后台 模板管理程序,html5页面跳转,企业网站管理系统 asp,马克斯X站h站源码程序黑色源码lzw

ALTER TABLE语句允许您重命名一个现有的表。它也可以被用于从现有的表添加,修改或删除一列,下面我们来看看alter语句的多种用法吧。

视频播客源码,vscode文件路径怎么写,删除 ubuntu 分区,tomcat怎么运行的,找法网 爬虫,反向代理 php程序,广西做seo优化费用,手机网站设计平台代码,源码 模板资源lzw

php 博客网站源码,vscode怎么运行xml,ubuntu 重设密码,登录tomcat报错404,sqlite数据表导出文件,web网络爬虫和网络爬虫,php 打包成exe,谷歌seo推广公司毕节,有cms的淘宝客网站,dede标签模板lzw

重命名表

重命名表的基本语法是:

这将重命名的供应商表供应商。

表中添加列(S)

语法#1

要添加到现有的表列,ALTER TABLE的语法是:

这会增加供应商表中的列称为supplier_name。

语法#2

要添加到现有表的多个列,ALTER TABLE的语法是:

这将增加两列(supplier_name市)的供应商表。

修改表中的列(S)

语法#1

要修改现有表列,ALTER TABLE的语法是:

这将修改所谓supplier_name,是一个VARCHAR2数据类型(100),并迫使列不允许空值的列。

语法#2

要修改现有表中的多个列,ALTER TABLE的语法是:

这将修改supplier_name和城市列。

(S)在一个表中删除列

语法#1

要删除一个现有的表列,ALTER TABLE的语法是:

这将下降supplier_name名为供应商的表列。

在表重命名列(S)

(新在Oracle 9i第2版)

语法#1

在Oracle9i第2版开始,你现在可以重命名列。

要在现有的表重命名列,ALTER TABLE的语法是:

This will rename the column called supplier_name to sname.

Acknowledgements: Thanks to Dave M., Craig A., and Susan W. for contributing to this solution!

Practice Exercise #1:

Based on the departments table below, rename the departments table to depts.

Solution:

The following ALTER TABLE statement would rename the departments table to depts:

Practice Exercise #2:

Based on the employees table below, add a column called salary that is a number(6) datatype.

Solution:

The following ALTER TABLE statement would add a salary column to the employees table:

Practice Exercise #3:

Based on the customers table below, add two columns – one column called contact_name that is a varchar2(50) datatype and one column called last_contacted that is a date datatype.

Solution:

The following ALTER TABLE statement would add the contact_name and last_contacted columns to the customers table:

Practice Exercise #4:

Based on the employees table below, change the employee_name column to a varchar2(75) datatype.

Solution:

The following ALTER TABLE statement would change the datatype for the employee_name column to varchar2(75):

Practice Exercise #5:

Based on the customers table below, change the customer_name column to NOT allow null values and change the state column to a varchar2(2) datatype.

Solution:

The following ALTER TABLE statement would modify the customer_name and state columns accordingly in the customers table:

Practice Exercise #6:

Based on the employees table below, drop the salary column.

Solution:

The following ALTER TABLE statement would drop the salary column from the employees table:

Practice Exercise #7:

Based on the departments table below, rename the department_name column to dept_name.

解决方案:

下面的ALTER TABLE语句将重新命名department_name列dept_name部门表:

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。