In phpMyAdmin, I wanted to copy a database to another name so I would effectively have 2 databases exactly the same. One as my oringinal and another for testing on the staging website site that I have.
There are three main options
structure only
structure and data
data only,
I need structure and data, however there are more checkbox options below;
CREATE DATABASE before copying //was checked by default
Add DROP TABLE / DROP VIEW
Add AUTO_INCREMENT value //was checked by default
Add constraints
Switch to copied database
What does "ADD AUTO_INCREMENT value" and "Add constraints" mean and if I copy structure and data doesnt any fields with AI get copied?
When you export / import a database including structure and data, phpmyadmin restores it in the same state as it was. The same applies when you copy the database.
Add AUTO_INCREMENT value simply set the auto_increment value correctly so you can correctly use the restored database. This is necessary in case phpmyadmin does some kind of bulk insert where the auto_increment is not incremented on each insert.
This is also needed to set the correct value, as you can insert then delete some data in your table, so in order to keep the data consistency you have to keep not only the exact ID but also not use an ID which had been used by an old row.
The Add constraints does exactly what it means, i.e. it restores all the constraints on the table in your database. This is also required if you want a complet dump.
For what you are trying to do, maybe a database replication would be better.
You can find information on replication here and here.
If the "Add AUTO_INCREMENT value" and "Add constraints" checkboxes are checked, the new table should have the same next autoindex and constraints like the copied table. All the fields with AI get filled
"Add AUTO_INCREMENT" is keep doing auto increment in new copied database. if we unchecked then it will stop auto increment from that fields. so, if we want maintain auto increment into new database as well then keep checked "Add AUTO_INCREMENT"
Related
Everytime I enter data into one of the SQL linked tables, some of the rows keep saying #deleted no matter what I do. The data is fine in the actual SQL server but not within Access. I never have used Access before so I have no idea what I'm doing. Please use the most non-tech savy dialog as possible... This is all so new to me and I am not good with technology at all.
I have tried refreshing the tables by going to the "Linked Table Manager" thing but that hasn't helped. I tried completely deleting the data from both Access and the SQL Server, re-entering it into the SQL server, and creating a new linked table within Access. I have tried exporting the data into Excel from the server and importing it into Access. None of it has worked. It's only the first 10 rows of data though... The rest of the table is completely fine and all the data has similar structure so I don't know why only the first 10 rows are being affected.
Ok, there are 3 things that often cause this.
1 - Make sure the sql table has a PK column. This is often (useally) a autonumber (incrementing by 1 integer column). So when you create the column in sql server, set it as primry key (a button in the menu can be hit to set PK using the sql manager). Then change in the property sheet the column to identify "yes" and it will set the starting number (1) and the increment (1) for you. Now add the other columns.
So Access needs a PK column.
If above was not your issue, then next up that is common is if you have a "bit" column in sql eerver. These can't be null, or access goes crazy. so if you have a bit column, then MAKE sure you set the default for that in the sql table designer as (0).
If the above don't fix your issue? Then number 3 on the list is to add what is called a row version column to the sql table. Simply add a timestamp column (this is NOT a date column, but is a time stamp row).
In ALL of the above cases, after you make the change to the sql server table, you have to re-link the access table. It is sufficient to right click on the table in Access, choose linked table manager, and then check box the table in queston, and hit ok. The link will be refreshed for you.
So the above are the 3 main issues. In most cases, the PK is the issue. However, if the table on SQL also has a trigger (that inserts) to other tables, then that table trigger has to be changed - but lets take this 1 step and soluion at a time.
As a general rule, Access needs a PK column when working with sql server. If you have that, then check the null "bit" issue - sql server tables need a default setting of 0 for those columns, and if they are null, then Access don't like that.
If both above issues are NOT your issue, then adding a column of timestamp to the sql table will fix this.
I am learning to use MYSQL-Workbench for inserting data into tables
My Problem::
I have two columns one for Sl_no and one for Name
Sl_no is the primary key which has auto increment checked as shown in
snapshot-1
If you look at Snapshot-2 auto_increment is not automatically
incremented when i keep adding the values
should i need to enable any option for this ?
Because Using the IDE should automatically add values(Since Sl_NO has
autoincrement enabled) but it is not doing so
I have to manually add it one after another
Snapshot-1
Snapshot-2
How can i resolve this ?
{EDIT}
I am using Windows-7 OS
As you can see i am clicking the marked area in the pic to apply
changes, but nothing is happening.
Should i need to enable any settings
UPDATE: It wasn't apparent right away that you're doing this from model and not directly in your db table.
To create your schema from model you need to do Forward Engineering and in the dialog choose Generate INSERT Statements for Tables.
Then go to the object browser in your MySQL connection, not your model. Fire select statement in query window or choose from context menu Select Rows - LIMIT 1000 and you'll see that your sl_no column is populated as expected.
BTW both mac and windows interfaces are identical.
Original answer:
You forgot to commit your changes by clicking Apply
And after reviewing the change script click Apply again.
After that you'll see your auto_increment column values populated
I was having a "coming soon" page with a sign up form. Since a couple of weeks I've switched to another web hosting and continue working on my new site at my new host, but continued to let the visitors sign up at my old host.
Now my have pointed my domain to my new hosting and want to export all new subscribers and import them into the new DB. Some rows might use same ID.
How can I easily export and merge a table from the old DB to the new one? Please note I don't wan't it to overwrite any row that has the same ID, if it does, I want it to add a new row instead.
I've tried exporting my table "wp_csp3_subscribers" from my old DB and imported it in my new one. But get an error saying ID already exists.
If you're using phpMyAdming (based on your tags), you can expand the export options by selecting "Custom - display all possible options" instead of the default "Quick - display only the minimal options".
Under the data dump options, choose "INSERT IGNORE statements", which will tell mySQL to ignore any errors with duplicate primary keys.
Taken from the mySQL documentation on the IGNORE option:
For example, without IGNORE, a row that duplicates an existing UNIQUE index or PRIMARY KEY value in the table causes a duplicate-key error and the statement is aborted. With IGNORE, the row still is not inserted, but no error is issued.
Hope this answers your question.
also, if you have two sql files from a dump, insert one normally, maybe with Enable foreign key checks unchecked, then your second file would like to concatenate the data, remove the DROP TABLE IF EXISTS and CREATE TABLE lines in that second file. Leave only the LOCK TABLES table WRITE; and inserts
I have a split form view with data coming from linked sql server (2008).
How do I go about updating the record?
Currently, it will not let me change anything in the text boxes i assume this is because the data is coming from linked tables?!
In order to update do i have to create command and coonn objects and program it in the usual vb manner?
And if so, what is the syntax for referencing the linked tables when creating the update query?
On my split form I dropped a button on there and I can see options to make it run macro, run code, etc etc, which one is suitable?
many thanks,
KS
First make sure the table was not linked read-only.
When you link to a remote table, Access will make it read-only if it is unable to identify a primary key or another combination of fields to uniquely identify each row. Sometimes, but not always, it may ask you to tell it which field(s) to use as the primary key if it is uncertain.
But this issue is simple to check. Open the linked table directly in Datasheet View and see whether you can edit any values. If not, re-link the table and look for an option to inform Access about the primary key.
If the link is not read-only, make sure your form's Allow Edits property is set as Yes.
Also you could try a simple form rather than a split form to determine whether something about the split form is causing the problem.
Solution:
MS Access barfs when trying to register tables with a primary key of type BigInt which is 8 bytes, Access can only handle Ints of 4 bytes. Workaround is below:
Drop the constraint (bigint PK) in SQL table
Create a new primary key (int) with identity seed
Link the table in MS Access
Drop new constraint (int PK) & Re-Add your previous constraint (bigint PK) in MS SQL
Voila!
Ok. Quick background:
MS Access 2003 with 2003/2003 format MDB file upgraded from Access 97.
For the purposes of this example, there are two tables.
Table 1
Asset
ID - (text 20)
ParentID - (text 20)
Other fields
AssetRels
ID - (text 20)
When a record is added to Asset, the ID is added to AssetRels.
From Asset.ID to AssetRels.ID there is a relationship that exists that enforces referential integrity with cascade update and cascade delete.
From AssetRels.ID to Asset.ParentID there is a relationship that enforces referential integrity with cascade update only.
I have 2 records in Asset
VACU0703200, NULL
VACU0703250, VACU0703200
In the data DB, I can go into the table and change VACU0703200 to VACU0704500 and the changes propogate as expected.
If I open the front end DB that links to the data DB, and try the same change (in the table directly) I get "Could not update; currently locked" (no, nothing about 'another session', that's the whole error message)
Both databases are set to "no lock" for the "default record locking"
Obviously, there is some difference in row/page/table level locks that is preventing the cascade update from working.
Does anyone know of some property settings that I can use somewhere to stop this error?
I would prefer not to have to remove the relationship, but otherwise I might have to, and handle it in code.
Edit: Cause is that the table contains a Memo field. Apparently via the linked table, having the Memo field overflow the 4K row size escalates to a table lock. which in turn triggers the problem.
Solution (hackish) is to prevent edits to the ID field on the form, and add a new form to rename. Save changes before opening the new form, and performing the update via an update query works.
I don't see why moving to the front end and editing this from a linked table should make any difference. I would however delete the table links, and then RE link. Often sometimes some properties are set up and read a time of linking, if you go to the back end database and change some of the table properties, often it's a very good idea to RE link the tables.
As a general rule, you more often have to do the above when you add new columns with linked tables to SQL server. However, I would suggest you delete your linked tables in the front end, and try RE linking, this should fix this problem.
Solution (hackish) is to prevent edits to the ID field on the form, and add a new form to rename. Save changes before opening the new form, and performing the update via an update query works.
The cause is a table lock escalation that occurs when the text overflows the 4K table row limit.