-
September 27th, 2011, 03:50 AM
#1
Copy row with unique constraint
Hi,
I am trying to add a new user to the MySQL database.
1) I am trying to add a new user. The mysql.user table has a lot of columns.
Whilst I could just insert specifying the Host & User fields, how would I copy a row, change a value or two and insert the updated row without having to specify all the columns.
For example how would I copy a row and insert that row where one or more columns has a unique constraint without having to name all the columns?
2) How do I get to see the 'mysql' database in MySQL Workbench?
-
September 27th, 2011, 04:08 AM
#2
Re: Copy row with unique constraint
PS
I should add that I know how to create a user.
This question is really about what is the simplest way to copy & paste a row from a table with lots of columns and make some changes.
-
September 27th, 2011, 07:36 AM
#3
Re: Copy row with unique constraint
About your first question, something like this should work:
Code:
INSERT INTO table (unq1, unq2, col3, col4, col5, ..., colN)
SELECT 'xxx' AS unq1, 'xxx' AS unq2, col3, col4, col5, ..., colN
FROM table WHERE ...;
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|