当前位置:网站首页>DML操作
DML操作
2022-06-24 00:33:00 【Rorschach379】
查询库名,表名,字段类型,注释等(mysql)
select table_schema,table_name,column_name,column_type,column_comment from information_schema.columns
where table_schema= ‘数据库库名’
–添加表注释(Oracle)
COMMENT ON TABLE STU_IN IS ‘学生信息表’;
–添加字段注释:(Oracle)
COMMENT ON COLUMN STU_IN.STU_ID IS ‘学号’;
Oracle查询表名,字段名,字段类型,注释等
SELECT t.TABLE_NAME tableName,t.COLUMN_NAME columnName,
t.DATA_TYPE dataType,a.COMMENTS
FROM USER_TAB_COLUMNS t
LEFT JOIN USER_COL_COMMENTS a
ON t.table_name = a.table_NAME
AND t.COLUMN_NAME = a.COLUMN_NAME
where t.TABLE_NAME like ‘ODS_%’
Oracle中如果要修改的字段数据为空时,则不会报这种类型的错误,可以进行如下语法的字段类型的修改。(user指代实际表名,name指代实际字段名)
alter table user modify (name varchar2(20));
要修改字段的新类型和原来的类型不兼容时,可以通过如下方式解决该问题:
1、修改原字段名name为临时字段name_new;
alter table user rename column name to name_new ;
=“alter table “&A2&” rename column “&B2&” to “&B2&”_new;”
2、添加一个新字段名称和原来字段名相同,name,类型为要修改的新类型;
如果有注释,要记得加上注释。
alter table user add(name varcher2(50));
=“alter table “&A21 &” add(”&B21& " varchar2(50));"
comment on column user.name is ‘居住地址’;
=“COMMENT ON COLUMN “& A21&”.”&B21&" IS"&" ‘“&D21&”’;"
3、把临时字段name_new的数据更新到新添加的字段name中;
update user set name = trim(name_new);
=“update “&A21&” set " &B21&” = trim(“&B21&”_new);"
4、删除临时字段name_new;
alter table user drop column name_new ;
=“alter table “&A21&” drop column “&B21&”_new ;”
边栏推荐
- [digital signal] spectrum refinement based on MATLAB analog window function [including Matlab source code 1906]
- 毕业设计-论文写作笔记【毕设题目类型、论文写作细节、毕设资料】
- 【CVPR 2022】高分辨率小目标检测:Cascaded Sparse Query for Accelerating High-Resolution Smal Object Detection
- 【红绿灯识别】基于matlab GUI红绿灯识别【含Matlab源码 1908期】
- Expander+listbox of WPF effect
- Android - JNI 开发你所需要知道的基础,Android工程师面试题
- Basic usage of oushudb database (medium)
- 【SPRS J P & RS 2022】小目标检测模块:A Normalized Gaussian Wasserstein Distance for Tiny Object Detection
- Building a digital software factory -- panoramic interpretation of one-stop Devops platform
- Experience summary of 9 Android interviews, bytes received, Ali, advanced Android interview answer
猜你喜欢

【ICPR 2021】遥感图中的密集小目标检测:Tiny Object Detection in Aerial Images

数据管理:业务数据清洗,落地实现方案

C language: structure array implementation to find the lowest student record

【虹科案例】3D数据如何成为可操作的信息?– 对象检测和跟踪

Expander+listbox of WPF effect

Detailed process from CPU fetching to sending control and microprogram control principle

Interview notes for Android outsourcing workers for 3 years. You still need to go to a large factory to learn and improve when you have the opportunity. Interview questions for Android Development Int

C language: on the right shift of matrix

Tiktok practice ~ one click registration and login process of mobile phone number and password (restrict mobile terminal login)

C language: sorting with custom functions
随机推荐
NLP工程师是干什么的?工作内容是什么?
What is the future development of palmprint recognition technology?
【小程序】实现双列商品效果
【第25天】给定一个长度为 n 的数组,统计每个数出现的次数 | 计数哈希
Andorid 开发艺术探索笔记(2),跨平台小程序开发框架
Vs2022 save formatting plug-in
逻辑的定义
Building a digital software factory -- panoramic interpretation of one-stop Devops platform
【小程序】相对路径和绝对路径的表示符
产业互联网时代将依靠源自于产业本身的产品、技术和模式来实现的
version `ZLIB_1.2.9‘ not found (required by /lib64/libpng16.so.16)
ARM学习(7) symbol 符号表以及调试
. Net
Social recruitment interview is indispensable -- 1000 interview questions for Android engineers from Internet companies
Drag and drop report design - new features of jimureport 1.4.0
Google Earth Engine(GEE)——NDVI、NDWI和NDBI用来进行增加分类精度的验证结果(随机森林和cart分类)
Version ` zlib 1.2.9 "not found (required by / lib64 / libpng16.so.16)
Basic usage of setfacl command
[traffic light identification] traffic light identification based on Matlab GUI [including Matlab source code 1908]
Vulnerability recurrence - redis vulnerability summary