oracle数据库连接问题,提示:table or view does not exist

luofuxian 2010-01-17 07:56:23
问题描述如题:
我的测试程序是这样写的:

string strConnectionString = "data source=ORCL;User ID=michael;Password=admin;";
OracleConnection con = new OracleConnection(strConnectionString);
OracleCommand com = new OracleCommand();
com.Connection = con;
com.CommandText = "select * from a";
con.Open();
OracleDataReader dr = com.ExecuteReader();
if (dr.Read())
Response.Write("read:"+dr[0].ToString());

补充:user id=michael;password=admin 或者user id=system;password=admin
我在pl/sql和sql*plus里面都试过可以的,即有权限访问这个表a;
请问下大家,因为对oracle不太熟,纯属刚学,是不是我安装oracle的时候少安装了什么或者有什么特别的配置需要配置吗?
...全文
1845 15 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
xray2005 2010-01-18
  • 打赏
  • 举报
回复
table or view does not exist 都告诉你了,没有这个a表或视图。

下面的你自己查询的结果,也告诉你了。
SQL> select * from a;
select * from a
*
ERROR at line 1:
ORA-00942: table or view does not exist


SQL> select * from a;
select * from a
*
ERROR at line 1:
ORA-00942: table or view does not exist


如果你的a表的确是存在的,那么到检查以下a的DBA权限是否已经给michael。
  • 打赏
  • 举报
回复
string strConnectionString = "data source=ORCL;User ID=michael;Password=admin;";
感觉这样只是指定了数据库实例,连上后可能缺省的数据库是系统数据库(在sql server里是master,oracle里应该类似)。
比如你的表a在数据库mydb里,那么用:
select * from mydb.a,应该可以
王向飞 2010-01-17
  • 打赏
  • 举报
回复
code=SQL]show user[/code]
所有的以DBA身份登陆的用户,即as sysdba的.用户统一是sys
只有一般用户登陆的时候show user才显示对应的用户名称
select * from sys.a
王向飞 2010-01-17
  • 打赏
  • 举报
回复
select * from system.a
luofuxian 2010-01-17
  • 打赏
  • 举报
回复
[Quote=引用 10 楼 wangminqi 的回复:]
试试  用户名(or 架构).表名  就好像sql server 的  dbo.表名

sysdba 会不会是表的拥有者(or 架构)

对oracle不是很熟


http://www.mybuffet.cn



[/Quote] as sysdba 是系统管理员的意思
wangminqi 2010-01-17
  • 打赏
  • 举报
回复
试试 用户名(or 架构).表名 就好像sql server 的 dbo.表名

sysdba 会不会是表的拥有者(or 架构)

对oracle不是很熟


http://www.mybuffet.cn


luofuxian 2010-01-17
  • 打赏
  • 举报
回复
问题似乎找到了,请看:
这是我登陆sql*plus时的情况

SQL> conn system/admin
Connected.
SQL> select * from a;
select * from a
*
ERROR at line 1:
ORA-00942: table or view does not exist


SQL> select * from a;
select * from a
*
ERROR at line 1:
ORA-00942: table or view does not exist


SQL> conn system/admin as sysdba
Connected.
SQL> select * from a;

no rows selected


SQL> conn system/admin as sysdba 这句没有增加"as sysdba"就没权限访问表a; 这是为什么?
luofuxian 2010-01-17
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 wuyq11 的回复:]
表不存在,用户名是否有操作权限
string constring = "Data Source=oracle;User Id=sys;Password=123;DBA Privilege=SYSDBA;"

[/Quote]
错误:
不支持关键字: “dba privilege”。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。

异常详细信息: System.ArgumentException: 不支持关键字: “dba privilege”。
luofuxian 2010-01-17
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 zhoukang0916 的回复:]
data source=ORCL
[/Quote]
你这个和我这个有区别吗,只不过大小写不一样罢了;
错误信息:
“/”应用程序中的服务器错误。
--------------------------------------------------------------------------------

ORA-00942: table or view does not exist

说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。

异常详细信息: System.Data.OracleClient.OracleException: ORA-00942: table or view does not exist


源错误:


行 41: com.CommandText = "select * from a";
行 42: con.Open();
行 43: OracleDataReader dr = com.ExecuteReader();
行 44: if (dr.Read())
行 45: Response.Write("read:"+dr[0].ToString());

alan0128 2010-01-17
  • 打赏
  • 举报
回复
OracleConnection con = new OracleConnection(@"data source=ORCL;User ID=michael;Password=admin");
luofuxian 2010-01-17
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 wuyq11 的回复:]
表不存在,用户名是否有操作权限
string constring = "Data Source=oracle;User Id=sys;Password=123;DBA Privilege=SYSDBA;"

[/Quote]
我在pl/sql和sql*plus 里面可以查询,即用的是同样的语句;
wuyq11 2010-01-17
  • 打赏
  • 举报
回复
表不存在,用户名是否有操作权限
string constring = "Data Source=oracle;User Id=sys;Password=123;DBA Privilege=SYSDBA;"
mngzilin 2010-01-17
  • 打赏
  • 举报
回复
权限不够

表名太短?
PandaIT 2010-01-17
  • 打赏
  • 举报
回复
data source=ORCL
PandaIT 2010-01-17
  • 打赏
  • 举报
回复
Data Source=TORCL;User Id=myUsername;Password=myPassword;
1073页啊,够爽吧: Introduction 15 New in This Release 15 Introduction to Toad 23 DB Admin Module 24 Toad and Oracle Enterprise Manager 29 Quick Search Bar 30 Additional Resources 31 Working with other Quest Products 32 Knowledge Xpert 32 Using SQL Optimizer with Toad 32 Benchmark Factory 33 Quest Code Tester Integration 35 Toad Basics 37 Toad Tips 37 Errors 37 RAC Support 37 Task Bar & Status Bar 38 Toolbars, Menus and Shortcut Keys 40 Installation and Administration of Toad 64 Window Privileges and Toad 64 Toad for Oracle, Read-Only 64 Registering Toad 65 Silent Installation 66 Group Policy Management 71 Citrix Support 71 SQL*Net Versions 72 Configuration Files 73 Server Side Objects Installation 93 Connecting to Oracle 97 Server Login Window 97 Create New Connection 99 Selecting Connection Color 101 SET ROLE 101 Auto Connect 103 Save Passwords for Connections 104 Select and View Favorite Connections 104 Organize your login display 105 Use Existing Connection 106 SQLNET Editor 106 LDAP Editor 107 Oracle Homes 108 TNSNames Editor 111 Tutorials 119 CodeXpert 119 PL/SQL Debugger 121 SQL*Loader 140 Team Coding 158 RMAN Templates 164 RMAN Scripts in Toad 164 Working with RMAN Templates 164 Executing RMAN Scripts from Toad 165 Comparing 166 Data Duplicates 166 Compare Single Objects 166 Comparing Databases 167 Comparing Data 174 Compare Files (Difference Viewer) 176 Comparing Schemas 180 Controlling Sessions 188 Select Session 188 End Connections 188 Test Connections 188 Configure User Lists 188 Session Information 189 Change Password 190 Commit & Rollback 190 Connect and Disconnect 191 DBMS_Flashback 191 Diagnosing Problems 193 View Extents 193 Identify Space Deficits 193 Log Switch Frequency Map 194 Tablespace Map 194 TKProf Interface Wizard 196 Undo Advisor 198 Segment Advisor 200 LogMiner Interface 203 Health Check 207 Trace File Browser 226 CodeXpert 231 Database Administration 259 Audit SQL/Sys Privs 259 NLS Parameters 260 Toad Features Security 260 ASM Manager 263 Audit Objects 269 Multiple Object Privileges 270 Oracle Parameters 272 Tablespaces 274 Redo Log Manager 282 Importing and Exporting Data 285 Data Pump 285 Export Dataset 304 Export DDL 310 Export File Browser 318 General Export 324 General Import 329 Generate Database Script 341 Generate Schema Script 342 Managing Projects 346 Using Automation Designer to Control Toad 346 Project Manager 387 Query Viewer 416 SQL Command Recall 418 Script Manager 419 Monitoring 431 Toad Server Statistics 431 SQL Monitor 432 Toad UNIX Monitor 432 ADDM/AWR 434 Database Browser 446 Database Monitor 449 Database Probe 453 Index Monitoring 458 Instance Manager 460 Session Browser 466 SGA Trace/Optimization 483 StatsPack Browser 486 Top Session Finder 495 Optimizing (Tuning) 499 DBMS_REDEFINITION Wizard 499 Estimate Index Size 500 Estimate Table Size 501 Explain Plan 503 Pinned Code 504 Repair Chained Rows 505 Rebuild Table 506 Unix Kernel Parms 507 Windows Registry Parms 508 Analyze All Objects 509 Profilers 512 Oracle Tuning 523 Rebuild Multiple Objects 525 Options 535 Formatting Options 535 Toad Options 536 Language Management 603 Printing 620 Printing 620 Print Grid 620 Report Link Designer 620 Reporting 623 Toad Control Files 623 Dependencies 624 ER Diagrams 624 Explain Plans 631 Code Road Map 636 HTML Schema Doc Generator 641 Master/Detail Browser 643 Reports Manager 648 Reporting from Data Grids 655 Spool SQL 659 Spool SQL 659 Utilities 660 Archive 660 Wrap Code 660 Service Manager 661 External tools 662 FTP 665 Java Manager 668 Network Utilities 672 Task Scheduler 676 Unix Job Scheduler 678 Source Control and Team Coding 693 Support for Version Control Products 693 Third Party File Based Source Control 694 Team Coding 697 Status in the Editor Status Bar or Team Coding Viewer Status Column 707 Detailed File Properties 708 Checking Objects and Scripts in and out 709 Using Automatic Check-in and Automatic Check-out 709 Manually check-in or check-out 709 Entering Comments on Check in or out 710 Check In All 711 Undo Checkout 712 Freezing an Object 713 TC Locks not selected 726 TC Locks selected 726 Working from the Command Line 738 Command Line Syntax 738 Converting Old Settings Files to Actions 743 Command Line Passwords 744 Export Tables, Views, SQL Queries from the Command Line 744 Run Analyze Objects from the Command Line 745 Run CodeXpert from the Command Line 750 Running Actions from the Command Line 751 Run Compare Databases from Command Prompt 754 Run Compare Schemas from a Command Prompt 757 Run Copy to another Schema from Command Prompt 757 Run Generate Database Script from a Command Prompt 758 Run Generate Schema Script from Command Line 760 Run Rebuild Objects from the Command Prompt 762 Run Reports Manager from the Command Line 766 Using Variables 768 Using Variables 768 Working with Code 769 Editor 769 Debugging 819 Query Builder 851 Working with Data 861 Column Names Supported 861 Graph Properties 861 OPS$ Accounts 861 Viewing or Hiding Docked Windows 862 Viewing Source Surrounding a PL/SQL Error 863 Dataset Operations 864 Data Grids 866 DBMS Output 881 Finding Data 883 Generate Test Data 890 Working with Database Objects 896 Schema Browser Overview 896 Auto-Refreshing the Datagrid 897 Icon Legend 898 Privileges 898 Schema Browser Toolbars 899 Statement Processing 900 Create Objects in Another Schema 900 Personalizing the Schema Browser 900 General Schema Browser Actions 903 Browser Filters 907 Clusters 912 Constraints 914 Contexts 917 DB Links 918 Dimensions 920 Directories 921 Favorites 923 Flashback Archives 924 Functions 926 Indexes 928 Invalid Objects 929 Java 931 Jobs 933 Libraries 936 Materialized Views (Snapshots) 938 Materialized View (Snapshot) Logs 940 Oracle Scheduler 941 Packages 953 Policies 955 Policy Groups 956 Procedures 957 Profiles 959 Queue Tables 960 Queues 964 Recycle Bin 966 Refresh Groups 968 Resource Consumer Groups 970 Resource Plans 972 Roles 974 Rollback Segments 975 Sequences 977 Synonyms 978 System Privileges 980 Tables 981 Tablespaces 996 Triggers 1002 Types 1004 Users 1010 Views 1012 Troubleshooting 1017 Unicode Troubleshooting 1017 Hints and Tips: Connecting To Personal Oracle 1018 Hints and Tips: Table Does Not Exist Errors 1019 Create Support Bundles 1019 Toad Advisor 1019 Contact Quest 1021 Contact Quest Support 1021 Contact Quest Software 1021 About Quest Software, Inc 1021 Appendix: Contact Quest 1022 Contact Quest Support 1022 Contact Quest Software 1022 About Quest Software, Inc 1022 Index 1023

62,243

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧