oracle中desc怎么用

作者:哈哈小脸 | 创建时间: 2023-06-21
Oracle的desc有以下两种用途: 1)desc 作为降序排序的关键字 2)desc + 表名:显示表的详细字段...
oracle中desc怎么用

操作方法

启动plsql并登陆oracle数据库

创建测试表 -- 创建表 create table TestTable ( id      varchar2(36) not null, colcode nvarchar2(50), colname nvarchar2(50) ); -- 给表名添加备注 comment on table TestTable is '测试表'; -- 添加主键 alter table TestTable add constraint ID primary key (ID);

插入测试数据(除了F8执行SQL之外,还需要点击【提交】按钮才能将数据插入到数据库) -- 添加测试数据 INSERT INTO TESTTABLE(ID, COLCODE, COLNAME) VALUES((select sys_guid() from dual), 'ColCode1', '名字1'); INSERT INTO TESTTABLE(ID, COLCODE, COLNAME) VALUES((select sys_guid() from dual), 'ColCode2', '名字2'); INSERT INTO TESTTABLE(ID, COLCODE, COLNAME) VALUES((select sys_guid() from dual), 'ColCode3', '名字3'); -- 查看插入的数据 select * from TESTTABLE

desc 作为降序排序的关键字,按照COLCODE 列降序展示表数据 SELECT * FROM TESTTABLE ORDER BY COLCODE DESC

【DESC + 表名】:显示表的详细字段(直接在Plsql的sql窗口中执行会报错)

点击plsql的【新建】图标,选择【command window】(命令窗口)

在【command window】中输入 DESC TESTTABLE 并回车,即可看到TESTTABLE 表的字段信息

点击展开全文

更多推荐