PostgresSql 中查询某张表中字段、字段类型、长度、主键、唯一、外键、null



select a.attname as 字段名称,format_type(a.atttypid,a.atttypmod) as 字段类型,
(case
when atttypmod-4>0 then atttypmod-4
else 0
end)字段长度,
(case
when (select count(*) from pg_constraint where conrelid = a.attrelid and conkey[1]=attnum and contype='p')>0  then 'Y'
else 'N'
end) as 主键,
(case
when (select count(*) from pg_constraint where conrelid = a.attrelid and conkey[1]=attnum and contype='u')>0  then 'Y'
else 'N'
end) as U,
(case
when (select count(*) from pg_constraint where conrelid = a.attrelid and conkey[1]=attnum and contype='f')>0  then 'Y'
else 'N'
end) as R,
(case
when a.attnotnull=true  then 'N'
else 'Y'
end) as 不是null,
col_description(a.attrelid,a.attnum) as comment,'XEditText' as control
from  pg_attribute a
where attstattarget=-1 and attrelid = (select oid from pg_class where relname ='user')

如user表执行结果如下:
在这里插入图片描述
参考原文:

### 实现多图片上传的功能 在 Vue3 和 Element Plus 中,`el-upload` 组件支持多种配置选项以满足不同的需求。为了实现多图片上传功能,可以通过调整 `limit`、`multiple` 等属性以及监听事件来完成。 以下是基于提供的引用内容和官方文档的一个完整示例: #### HTML 结构 ```html <template> <div> <!-- 使用 el-upload --> <el-upload action="https://jsonplaceholder.typicode.com/posts/" multiple :limit="3" list-type="picture-card" :on-exceed="handleExceed" :file-list="fileList" :auto-upload="false" :before-upload="beforeUpload"> <el-icon><Plus /></el-icon> </el-upload> <el-button style="margin-top: 20px;" @click="submitUpload">上传</el-button> </div> </template> ``` #### JavaScript 部分 ```javascript <script setup> import { ref } from 'vue'; import { ElMessage } from 'element-plus'; const fileList = ref([]); // 文件列 // 超过限制时的回调函数 const handleExceed = () => { ElMessage.warning('最多只能上传三图片'); }; // 自定义校验逻辑 const beforeUpload = (file) => { const isJPGorPNG = file.type === 'image/jpeg' || file.type === 'image/png'; if (!isJPGorPNG) { ElMessage.error('仅允许上传 JPG 或 PNG 格式的图片!'); } const isLt2M = file.size / 1024 / 1024 < 2; if (!isLt2M) { ElMessage.error('图片大小不能超过 2MB!'); } return isJPGorPNG && isLt2M; }; // 提交上传按钮点击事件 const submitUpload = () => { console.log(fileList.value, '待上传文件列'); // 可在此处调用自定义方法提交到服务器 }; </script> ``` --- #### 关参数说明 - **`action`**: 设置上传的目标 URL 地址[^1]。 - **`multiple`**: 是否允许多选文件,默认为 `false`。将其设为 `true` 即可开启多图上传模式。 - **`list-type`**: 图片上传组件展示样式,常见的有 `"text"`(默认)、`"picture"` 和 `"picture-card"`。 - **`:limit`**: 限定最大上传数量,超出会触发 `exceed` 方法。 - **`:on-exceed`**: 当上传文件数超限时触发的方法。 - **`:before-upload`**: 在上传前对文件进行验证的操作钩子[^2]。 - **`:auto-upload`**: 控制是否自动上传文件。如果设置为 `false`,则需要手动触发单提交操作。 --- #### 注意事项 当 `auto-upload` 设为 `false` 时,`before-upload` 不会被触发。因此,在这种情况下,建议将所有的校验逻辑放在其他地方处理,比如通过单提交的方式统一管理。 另,实际项目中可能还需要对接 OSS 接口或其他存储服务。此时可以参考引用中的代码片段[^3],动态生成上传地址并绑定成功后的回调函数。 --- ###
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值