I want to easily paste a DUMPed table definition in MySQL into Confluence. I'm sure you've had that happen to you.
I want to paste DUMPed table definitions in MySQL to Dev.to easily. I'm sure you have.
It's a bit tedious to write table definitions for a DB in a document to be delivered. It's not productive at all, and I want to get it done in one shot.
Target
From
+--------------------+------------------+-----------------+------+-----+---------+-----------------------------+---------------------------------+--------------------------------------------------------+
| Field | Type | Collation | Null | Key | Default | Extra | Privileges | Comment |
+--------------------+------------------+-----------------+------+-----+---------+-----------------------------+---------------------------------+--------------------------------------------------------+
| id | int(10) unsigned | NULL | NO | PRI | NULL | auto_increment | select,insert,update,references | ID |
| name | varchar(256) | utf8_general_ci | YES | | NULL | | select,insert,update,references | 名称 |
+--------------------+------------------+-----------------+------+-----+---------+-----------------------------+---------------------------------+--------------------------------------------------------+
to
One-liner
Confluence Wiki
$ mysql -h (host) -u (user) -p (schema) -e 'show full columns from (table)' | sed 's/^/|/g;s/$/|/g;s/\t/ | /g;1 s/|/||/g'
Markdown
$ mysql -h (host) -u (user) -p (schema) -e 'show full columns from (table)' | sed -E "s/^/\| /g;s/$/ \|/g;s/\t/ \| /g;1{h; p; s/\w+/:-:/g}"
By using xsel or pbcopy, save it in clipboard in one shot.
Top comments (0)