SQL Developer show the schema prefix
i.e in package name now showing prefix will loading the sql developer
When browsing the contents of the Oracle Database, in this case PL/SQL programs, we show you the code that's stored in the database.
We add onto that,
'CREATE OR REPLACE'
We do not, add the schema prefix.
If I make changes to this and hit COMPILE, we maintain the schema (HR2) for you, even though I'm logged in as HR.
If you want the PL/SQL code with the schema prefix attached, use the DDL command.
If you maintain your source code in files and open said files in Oracle SQL Developer, you'll of course see the schema prefix in your code, assuming you put it there.
Related
There is a statements logging in Oracle SQLDeveloper:
Is there any way to export them as plain text or log them to file?
UPD: The reason I want to collect statements to file is for easy diff (to compare expected vs truncated export). I have a schema which export is not completely performed by 'Tools -> Database export'. Indexes, constraints, packages and synonyms are missing in resulting file while they are obviously present in database and visible in SQLDeveloper.
No, just copy and paste.
You could always do a client based jdbc trace or a database session trace if you wanted that to go to a file.
So, I am relatively new to MySQL and recently, I was asked to create a query that utilizes the BACKUP command in order to copy a table to a given destination folder. I was provided text from an SQL tutorial in w3schools.com, however, when I attempted to follow the format, I was informed that "BACKUP is not valid at this position, expecting: EOF, BEGIN, CATCH, CHECKSUM, COMMIT, DEALLOCATE,..". So, I was wondering, what is the proper syntax for using the BACKUP command in a query?
I have attempted several actions in order to resolve the issue, but none of them were successful. I have tried;
1# Executing a query with and without the underlying table saved in a file folder.
2# Using BACKUP for a database in case the problem was with tables.
3# Starting with BEGIN, DO, and mysqldump.
4# Removing TABLE.
5# Adding an opening parenthesis after the name of the table and a closing parenthesis after the name of the destination.
I do not feel comfortable sharing my own table and destination folder, but here is what I was supposed to use for reference. My code follows the same format;
What I was supposed to use for reference
BACKUP DATABASE Is not part of MySQL syntax. I believe you may be thinking of the SQL Server statement.
For MySQL you will likely want to use the mysqldump utility (which is a separate concept from SQL queries). Or possibly some solution involving the SELECT ... INTO OUTFILE variant of the SELECT...INTO statement.
I followed the following MDSN tutorial:
http://www.asp.net/mvc/tutorials/mvc-4/getting-started-with-aspnet-mvc4/adding-a-model
Then I tried this guide according to my needs and I set up a database GAMES.MDF.
Then, I deleted the database and set it up again, is supposedly work (I can write and read data), but there is no such database in the APP_DATA folder. It seems to exist, but somewhere else on my PC.
I even tried a new project and it did not work, works but not in the library, and it even uses the data I created before. I even deleted the DB from SQL Server Management Studio 2008.
How do I delete it permanently, not to remain any trace of it?
Check for the connection string in the web.config - You'll probably see the file location there.
Your connection string should ideally name the database you want to use. I would not recommend specifying the MDF file, unless you know you are using SQL Express. Source: https://social.msdn.microsoft.com/Forums/sqlserver/en-US/f21c0728-935d-492a-baaf-ff2704e3683b/attachdbfilename-option-in-connection-string?forum=sqldataaccess0
Instead, this is how it is done on SQL Server:
initial catalog=MyDatabase
To be sure you are accessing the database you think you are, run this SQL query through your app, using your connection string, and look at the physical file location of your MDF file. This query is handy for knowing which DB is tied to which DB files.
select * from [dbo].[database_files]
As far as actually clearing the DB, this article deals with managing database initializers and seeds. You might be experiencing a problem due to that:
How to delete and recreate from scratch an existing EF Code first database
Outside of EF, SQL deletes databases like this:
use master
drop database MyDatabase
In T-SQL (Microsoft SQL 2008), how can I make a new database which will have the same schemas, tables, table columns, indexes, constraints, and foreign keys, but will not contain any data from the original database?
Note: making a full copy, then removing all data is not a solution in my case, since the database is quite big, and such full copy will spend too much time.
See here for instructions: How To Script Out The Whole Database In SQL Server 2005 and SQL Server 2008
In SQL Management Studio, right click on the database and select "Script database as"
http://msdn.microsoft.com/en-us/library/ms178078.aspx
You can then use the script to create an empty one.
Edit : OP did say 2008
I use liquibase for this purpose. Just point liquibase to a different server and it will use your changelog to bring the second database up to date, schema wise. It has the added benefit that the changelog file gets stored in source control and so I can have tagged versions of it, allowing me to restore a database to what a specific version of my app is expecting.
A client has outgrown their Access database, and now I need to convert it to PostgreSQL. I don't have a lot of Access experience, so at first blush it seems like the best solution is to just export the data using text files or something.
Does anyone have any good suggestions for an easy way to get the DDL and data out of Access and into something real?
Based on http://www.postgresonline.com/journal/archives/24-Using-MS-Access-with-PostgreSQL.html but updated for Access 2019 with more details:
Install the PostgreSQL ODBC drivers.
You may have this already installed from installing PostgreSQL. If not, you can install them from https://www.postgresql.org/ftp/odbc/versions/msi/.
You should install the 32-bit driver if your Access is 32-bit and the 64-bit driver if Access is 64-bit. You can see if Access is 32-bit or 64-bit through File > Account > About Access.
Uninstall old versions of the PostgreSQL driver before installing a new one.
See Setting up PostgreSQL ODBC on Windows for more tips.
External Data > New Data Source > From Other Sources > ODBC Database. The keyboard shortcut for this is Alt > X > N1 > T > C.
Choose Link to the data source by creating a linked table, and press OK.
Next to DSN Name, click New...
Choose PostgreSQL Unicode if your databases is UTF-8 or a non Latin Encoding. Choose PostgreSQL ANSI if your database encoding is SQL_ASCII, EUC_JP, BIG5, Shift-JIS, or a LATIN character set. Databases made from Access 2000 or later are in UTF-8. Choose the 64-bit version if Access is 64-bit. Click Next >.
As the dialog says, "Type in the name of the file data source you want to save the connection to. Or, find the location to save to by clicking Browse." Click Next >. Click Finish.
Fill in the fields Database, Server, Port, User Name, and Password.
Click Connection and uncheck Bools as char.
Click Page 2 and check True is -1, and uncheck Updatable Cursors. Click OK. Click OK.
If you get an error that says "A connection could not be made using the file data source parameters entered", open ODBC Data Sources (64-bit) from the Start menu (or ODBC Administrator from Control Panel for Windows 7 or earlier), click Add..., choose PostgreSQL Unicode(x64), click Finish, enter the details for your database, and click Test.
Select the newly created .dsn file and click OK.
Now select the tables you want and click Save Password. If you are missing primary keys on tables, Access will prompt you for what fields or set of fields you would like to use as the primary key. This doesn't make any structural changes to the actual table, but in the linked structure, Access will pretend this is the primary key and use that accordingly for table updates and such. This is particularly useful for views where the concept of primary keys does not exist and you want your updateable views to be updateable from Access. If you click OK or Cancel to the question without picking a set of fields, that table will be marked as readonly, which is the desired behavior for a lot of reporting views.
To export data from an Access table to PostgreSQL:
Select the table.
Rename the table to what you want it to be named.
Make sure the default schema of the user you are using in Postgres, is the schema you want to export the data to.
External Data > More (in the Export section) > ODBC Database and select the DSN you created.
One gotcha here is that PostgreSQL will maintain the casing of the fields in the table and the table name, so it's best to rename all your fields to lowercase first so you don't have to be quoting them every time you use them.
Install Postgres ODBC driver on Windows computer.
Create a data source with "PostgreSQL Unicode" driver to your new database
For every table:
Use "File -> Export" choose type "ODBC Databases"
Confirm table name
Choose "Computer data source"
Select your data source
Works well if you do not have too many tables. I needed to automate this so I have created an VBS script which just issued keyboard strokes in proper time, like this:
set shell=CreateObject("Wscript.Shell")
shell.Run("db1.mdb")
WScript.Sleep(5000);
shell.sendkeys("tablename1");
WScript.Sleep(1000);
shell.sendkeys("%fx"); ' Menu File, Export
WScript.Sleep(1000);
shell.sendkeys("%todbc"); ' Type: ODBC Databases
shell.sendkeys("~"); ' Enter
etc.
You should be able to write something that can see them both with ODBC or something, but failing that you could dump it to a text file or use a commercial tool.
This is an old script that I has not been updated in a while, but I used for a similar purpose: http://code.activestate.com/recipes/52267/
Another commercial option: http://www.datanamic.com/dbzipper/index.html
Access is a great program, but is hindered by its inability to export or connect to external ODBC sources easily.
Using the ODBC driver would be ideal, but the setup looks kind of daunting.
So I just exported the tables one by one to CSV files, then imported each one to the Postgres db through DBeaver, a really nice, free db admin tool - check it out here - https://dbeaver.io.