Oracle SQL Plus 未显示所有表列
Posted
技术标签:
【中文标题】Oracle SQL Plus 未显示所有表列【英文标题】:Oracle SQL Plus not all table columns displayed 【发布时间】:2017-05-21 09:13:12 【问题描述】:我已经创建了这张表:
CREATE TABLE PRODUCT (
P_CODE CHAR(8),
P_DESCRIPT CHAR(200),
P_INDATE CHAR(20),
P_ONHAND INTEGER,
P_MIN INTEGER,
P_PRICE NUMBER,
P_DISCOUNT NUMBER,
V_CODE CHAR(5)
);
我在表格中插入了以下数据:
INSERT INTO PRODUCT VALUES ('11QER/31','Power painter, 15 psi, 3-nozzle','12/2/96',8,5,109.99,0.00,25595);
INSERT INTO PRODUCT VALUES ('13-Q2/P2','7.25-in. pwr. Saw blade','11/12/96',32,15,14.99,0.05,21344);
INSERT INTO PRODUCT VALUES ('14-Q1/L3','9.00-in. pwr. Saw blade','11/12/96',18,12,17.49,0.00,21344);
INSERT INTO PRODUCT VALUES ('156-QQ2','Hrd. Cloth, 1/4-in., 2x50','8/14/96',15,8,39.95,0.00,23119);
INSERT INTO PRODUCT VALUES ('1558-QW1','Hrd. Cloth, 1/2-in., 3x50','8/14/96',23,5,43.99,0.00,23119);
INSERT INTO PRODUCT VALUES ('2232/QTY','B&D jigsaw, 12-in, blade','10/29/96',8,5,109.92,0.05,24288);
INSERT INTO PRODUCT VALUES ('2232/QWE','B&D jigsaw, 8-in, blade','9/23/96',6,5,99.87,0.05,24288);
INSERT INTO PRODUCT VALUES ('2238/QPD','B&D cordless drill, 1/2-in.','10/19/96',12,5,38.95,0.05,25595);
INSERT INTO PRODUCT VALUES ('23109-HB','Claw hammer','11/19/96',23,10,9.95,0.10,21225);
INSERT INTO PRODUCT VALUES ('23114-AA','Sledge hammer, 12 lb.','12/1/96',8,5,14.40,0.05,null);
INSERT INTO PRODUCT VALUES ('54778-2T','Rat-tail file, 1/8-in. fine','6/14/96',43,20,4.99,0.00,'21344');
INSERT INTO PRODUCT VALUES ('89-WRE-Q','Hicut chain saw, 16 in.','7/6/96',11,5,256.99,0.05,'24288');
INSERT INTO PRODUCT VALUES ('PVC23DAT','PVC pipe, 3.5-in., 8-ft','12/19/96',188,75,5.87,0.00,null);
INSERT INTO PRODUCT VALUES ('SM-18277','1.25-in. metal screw, 25','11/28/96',172,75,6.99,0.00,'21225');
INSERT INTO PRODUCT VALUES ('SW-23116','2.5-in. wd. screw, 50','9/23/96',237,100,8.45,0.00,'21231');
INSERT INTO PRODUCT VALUES ('WR3/TT3','Steel matting, 4''x8''x1/6", .5" mesh','11/16/96',18,5,119.95,0.10,'25595');
INSERT INTO PRODUCT VALUES ('11QER/31','Power painter, 15 psi, 3-nozzle','12/2/96',8,5,109.99,0.00,25595);
INSERT INTO PRODUCT VALUES ('13-Q2/P2','7.25-in. pwr. Saw blade','11/12/96',32,15,14.99,0.05,21344);
INSERT INTO PRODUCT VALUES ('14-Q1/L3','9.00-in. pwr. Saw blade','11/12/96',18,12,17.49,0.00,21344);
INSERT INTO PRODUCT VALUES ('156-QQ2','Hrd. Cloth, 1/4-in., 2x50','8/14/96',15,8,39.95,0.00,23119);
INSERT INTO PRODUCT VALUES ('1558-QW1','Hrd. Cloth, 1/2-in., 3x50','8/14/96',23,5,43.99,0.00,23119);
INSERT INTO PRODUCT VALUES ('2232/QTY','B&D jigsaw, 12-in, blade','10/29/96',8,5,109.92,0.05,24288);
INSERT INTO PRODUCT VALUES ('2232/QWE','B&D jigsaw, 8-in, blade','9/23/96',6,5,99.87,0.05,24288);
INSERT INTO PRODUCT VALUES ('2238/QPD','B&D cordless drill, 1/2-in.','10/19/96',12,5,38.95,0.05,25595);
INSERT INTO PRODUCT VALUES ('23109-HB','Claw hammer','11/19/96',23,10,9.95,0.10,21225);
INSERT INTO PRODUCT VALUES ('23114-AA','Sledge hammer, 12 lb.','12/1/96',8,5,14.40,0.05,null);
INSERT INTO PRODUCT VALUES ('54778-2T','Rat-tail file, 1/8-in. fine','6/14/96',43,20,4.99,0.00,'21344');
INSERT INTO PRODUCT VALUES ('89-WRE-Q','Hicut chain saw, 16 in.','7/6/96',11,5,256.99,0.05,'24288');
INSERT INTO PRODUCT VALUES ('PVC23DAT','PVC pipe, 3.5-in., 8-ft','12/19/96',188,75,5.87,0.00,null);
INSERT INTO PRODUCT VALUES ('SM-18277','1.25-in. metal screw, 25','11/28/96',172,75,6.99,0.00,'21225');
INSERT INTO PRODUCT VALUES ('SW-23116','2.5-in. wd. screw, 50','9/23/96',237,100,8.45,0.00,'21231');
INSERT INTO PRODUCT VALUES ('WR3/TT3','Steel matting, 4''x8''x1/6", .5" mesh','11/16/96',18,5,119.95,0.10,'25595');
现在当我执行以下操作时:
SELECT * FROM PRODUCT;
只返回前 4 列!
我尝试设置以下内容:
SET WRAP ON
SET TERMOUT OFF
SET VERIFY OFF
SET TRIMSPOOL OFF
SET LINESIZE 2000
SET LONG 200000
SET PAGES 0
现在只出现两列。
请帮忙。
【问题讨论】:
【参考方案1】:如果该列应该是CHAR(200)
,那么您应该不理会它——不要仅仅因为您无法正确显示它而将其更改为CHAR(50)
。
相反,在查询表时只显示前 50 个字符可能没问题。您可以在查询本身中执行此操作,如下所示:
select p_code, substr(p_descript, 1, 50) as p_descript, p_indate, ...
或者,您可以使用 SQL Plus 命令告诉 SQL Plus 以 50 个字符的宽度显示列 - 您试图这样做,但您没有找到正确的命令。它是column
命令;特别是在这种情况下:
column p_descript format a50
(注意后面没有分号;
,因为它不是 SQL 命令)这将包装实际上超过 50 个字符的值。如果您希望截断它们,请发出额外的 SQL Plus 命令:
set wrap off
【讨论】:
以上是关于Oracle SQL Plus 未显示所有表列的主要内容,如果未能解决你的问题,请参考以下文章
如何使用 SQL*Plus 在 Oracle 11g 中显示数据库
我安装了oracle,可以在SQL\PLUS下登录,但是当我输入startup mount时,显示权限不足