-
Notifications
You must be signed in to change notification settings - Fork 1
/
sql.notes
69 lines (52 loc) · 2.84 KB
/
sql.notes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
### Start mysqld, log in as root, use the correct db, and describe it:
Joels-MacBook-Pro-2:PHP-Email-Reminder joel$ sudo mysqld_safe
Password:
140523 07:43:57 mysqld_safe Logging to '/usr/local/mysql/data/Joels-MacBook-Pro-2.local.err'.
140523 07:43:57 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
Joels-MacBook-Pro-2:PHP-Email-Reminder joel$ mysql --user=root
mysql> use test;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> dest test;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'dest test' at line 1
mysql> show tables;
+----------------+
| Tables_in_test |
+----------------+
| client_contact |
+----------------+
1 row in set (0.00 sec)
### Show create table
CREATE TABLE `client_contact` (
`email_addr` varchar(128) NOT NULL DEFAULT '',
`target_date` date NOT NULL DEFAULT '0000-00-00',
`date_added` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`action_step1` text,
`action_step1_date_sent` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
`action_step2` text,
`action_step2_date_sent` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
`action_step3` text,
`action_step3_date_sent` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00'
) ENGINE=InnoDB DEFAULT CHARSET=latin1
### Describe table
mysql> desc client_contact;
+------------------------+--------------+------+-----+---------------------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------------------+--------------+------+-----+---------------------+-------+
| email_addr | varchar(128) | NO | | | |
| date_added | timestamp | NO | | CURRENT_TIMESTAMP | |
| action_step1 | text | YES | | NULL | |
| action_step1_date_sent | timestamp | NO | | 0000-00-00 00:00:00 | |
| action_step2 | text | YES | | NULL | |
| action_step2_date_sent | timestamp | NO | | 0000-00-00 00:00:00 | |
| action_step3 | text | YES | | NULL | |
| action_step3_date_sent | timestamp | NO | | 0000-00-00 00:00:00 | |
+------------------------+--------------+------+-----+---------------------+-------+
8 rows in set (0.01 sec)
### Create the user who will connect:
grant all privileges on test.* to 'contactor'@'localhost' identified by '7sdfa3w8';
### Update table to have a 'target_date' column:
mysql> alter table client_contact add column target_date date not null default '0000-00-00' after email_addr;
Query OK, 0 rows affected (0.06 sec)
Records: 0 Duplicates: 0 Warnings: 0