r/DatabaseHelp • u/Phill544 • May 26 '17
Figuring out SQL database name.
I am writing a C# program that I want to be able to query and add things to a SQL database as an assignment. Online I found that you can use the code block
SqlConnection myConnection = new SqlConnection("user id=username;" +
"password=password;server=serverurl;" +
"Trusted_Connection=yes;" +
"database=database; " +
"connection timeout=30");I know my user ID and password and the server url as I have my own login. But I'm wondering how I find out the database name so I can add it to the string.
I don't think I have admin rights as I can't create new databases,I get the error
SQL> CREATE DATABASE assignment3;
CREATE DATABASE assignment3
*
ERROR at line 1:
ORA-01501: CREATE DATABASE failed
ORA-01100: database already mountedI can however create tables, and if I use the "SHOW DATABASES;" command it doesn't return an error, but it does however return a blank line. Any help would be greatly appreciated.
Thanks!
View all comments
Show parent comment
2
u/Rehd May 26 '17
"What Oracle calls a "database" is generally different than what most other database products call a "database". A "database" in MySQL or SQL Server is much closer to what Oracle calls a "schema" which is the set of objects owned by a particular user. In Oracle, you would generally only have one database per server (a large server might have a handful of databases on it) where each database has many different schemas."
Sauce
That part, I can't really help with. I've dabbled in PHP but I am terrible at C# and have limited exposure there. I think an oracle subreddit or the C# sub may be able to help better with that question.
You should be able to do that with C#.
I think this answer has a great template and dll reference for you that you can use.
Here's a comparison for SQL Server / Oracle.
Oracle: Database = SQL Server: Instance
Oracle: Tablespace = SQL Server: Database
Oracle: Table = SQL Server: Table
So I would say you need to connect to a data source, so you'll create a connection string for your oracle instance. I believe what you need to create is a tablespace, not a database, and that's what you should be looking for as well. Then you can create tables in that tablespace once you have a user in place too.