Using MySQL Workbench, how can I tell if a column has the AUTO INCREMENT property? - mysql-workbench

I've imported several tables from a local MySQL server to a DigitalOcean managed database. Everything seems to have worked OK, all the data and keys are there, but I cannot tell in MySQL Workbench if the fields that are supposed to be AUTO INCREMENT are, in fact, AUTO INCREMENT? I've used TablePlus to look at the tables and it does show that the correct fields have that property but I can't see it in MySQL Workbench. Does MySQL Workbench not show that property or am I just missing something?

Related

Crystal Reports ODBC connection: the database table <tablename> cannot be found

When running (or verifying the database) for a report in Crystal Reports 10, I am getting the message:
"The database table "SomeTable" cannot be found. Proceed to remove this table from the report?"
for multiple tables.
The report used to work fine. The report is getting data from multiple sources, and the missing tables are those that are coming from an ODBC connection to a SQL Server DB. I think the issue may be that when the report was created, the ODBC was pointing at a different instance of the database (same structures, just different location.)
I've checked and the report user has all the required permissions on the new database.
In Crystal, if you ignore the messages the report seems to run fine. However when deploying the report to be run from within the Crystal Report Viewer in a website, it is throwing a File I/O error.
This very handy blog post provides the solution: https://wisdomofsolomon.wordpress.com/2011/06/18/crystal-reports-tables-not-found-during-verify-database/
By running Show SQL Query you can see that the generated query is running SQL like
select * from databasename.dbo.SomeTable
It's the databasename part of that that seems to be causing the problem (although as far as I could tell, in my case the DB name isn't any different between the old DB connection and the new one in my case.) Amending the table queries to remove the databasename from the SQL solved the problem for me.
You can do this as follows:
go to Database / Set Datasource Location in the menus.
drill down in the report tree to the tables that are causing a problem
Under Properties, click Overriden Qualified Table Name:
In the text box, type the name of the table without the database name (e.g. dbo.SomeTable)
Do this for all the tables causing a problem
(As a comment on that blog post points out, you could also create a new connection and replace the tables with the equivalents from that new datasource, but that leaves you with the fully qualified table name from the new connection - so you might get the same problem again in future.)
in Crystal, under file and options and database tab, the data explorer must have tables checked. This is not an easy feature to know about

Netbeans 7.4: Creating entity classes (JPA) from java db embedded database

I am using Netbeans 7.4 to build my application. And also, I am using embedded java db. Now, I want to generate my JPA entities from my database from my database.
But, when I
rightclick my package -> New -> Entity classes from database, select my database, Available Tables is not showing up even a single one of the tables inside ANK schema.
One more strange thing I noticed is when I connect my db from Netbeans services tab, two schema options appear. First, APP in bold, second Other schemas. Schema APP don't have any tables. The tables are in ANK schema in Other schemas.
Can anybody tell me where I could have gone wrong?
I don't even know if I should be using java db, or I should go for pretty appealing h2, HSQL or some matured db like mysql.
The Nebeans interface to Derby is a bit tricky.
When creating a new database, only the APP schema is created by default (except for the SYS* schemas).
When you connect to the database without specifying a username, your default schema becomes APP
When connecting as user john, your default schema becomes john, BUT the schema john is NOT created, until you create an SQL object in it.
This means that if you create an initial connection to Derby in Netbeans as user john, you cannot choose john as the schema for the connection in the pull-down menu, because it has not been created yet. If you then choose another schema, create your table, disconnect and then create another connection you will be able to choose john as your schema, and you will find the table you created with the previous connection.
Even though you chose a different schema in the pull-down menu for the first connection, a schema with the same name as the username you connect as is created and set as default before starting to execute the create table statement.

Mysql Workbench Reverse Engineer function doesn't generate relationship "Lines" between tables

I just get a new project that need to work with a DB nobody knows about the structure about it. It is on the Mysql DB so I tried to use mySQL Workbench to export EER Diagram from this DB by using the Reverse Engineer function as many others recommended
I did get tables from the DB...but JUST tables!! no relationship that is the lines connect tables. Did I do something wrong or it is just because the ER Diagram from MySql Workbench is supposed to be like that?
Can anyone recommend tools that can export ER Diagram from existed DB? Include the relationship lines...
Relationships are only shown for foreign keys (how could MySQL Workbench otherwise know). If your tables have no foreign keys (e.g. because they are still using the MyIASM table engine instead of InnoDB) you won't get any relationships.

Delete database. Entity Framework

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

Convert Access to PostgreSQL?

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.