浅谈“Mysql”的基础操作语句
时间:2021-07-01 10:21:17
帮助过:7人阅读
your MySQL server version
for the
right syntax
to use near
‘\)‘ at line
1
2 mysql
> create table qq_user(id
int primary key );
3 Query OK,
0 rows affected (
0.01 sec)
4
5 mysql
> show tables;
6 +------------------+
7 | Tables_in_systop
|
8 +------------------+
9 | qq_user
|
10 +------------------+
11 1 row
in set (
0.00 sec)
12
13 mysql
>
14 mysql
>
15 mysql
>
16 mysql
>
17 mysql
>
18 mysql
>
19 mysql
>
20 mysql
>
21 mysql
>
22 mysql
>
23 mysql
>
24 mysql
> create table qq_user(id
int primary key )
25 -> create table qq_user(id
/;
int primary key )
26 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
‘create table qq_user(id/‘ at line
2
27 ->
28 -> ;
29 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
‘int primary key )‘ at line
1
30
31 mysql
> create table qq_user(
32 -> qq_id
bigint primary key,
33 -> Password nvrchar(
50)
not null,
34 -> ;
35 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
‘nvrchar(50) not null,‘ at line
3
36 mysql
> create table qq_user(
37 -> ;
38 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
‘‘ at line
1
39 mysql
> show tables;
40 +------------------+
41 | Tables_in_systop
|
42 +------------------+
43 | qq_user
|
44 +------------------+
45 1 row
in set (
0.00 sec)
46
47 mysql
> drop table qq_user;
48 Query OK,
0 rows affected (
0.00 sec)
49
50 mysql
> show tables;
51 Empty
set (
0.00 sec)
52
53 mysql
>
54 mysql
>
55 mysql
> create table qq_user(
56 -> qq_id
bigint primary key,
57 -> Password
nvarchar(
50)
not null,
58 -> LastLoginTime
datetime,
59 -> Oline
int,
60 -> Level int);
61 Query OK,
0 rows affected (
0.00 sec)
62
63 mysql
> show tables;
64 +------------------+
65 | Tables_in_systop
|
66 +------------------+
67 | qq_user
|
68 +------------------+
69 1 row
in set (
0.00 sec)
70
71 mysql
> descl
72 -> ;
73 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
‘descl‘ at line
1
74 mysql
> desc;
75 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
‘‘ at line
1
76 mysql
> desc qq_user;
77 +---------------+-------------+------+-----+---------+-------+
78 | Field
| Type
| Null | Key | Default | Extra
|
79 +---------------+-------------+------+-----+---------+-------+
80 | qq_id
| bigint(
20)
| NO
| PRI
| NULL | |
81 | Password
| varchar(
50)
| NO
| | NULL | |
82 | LastLoginTime
| datetime | YES
| | NULL | |
83 | Oline
| int(
11)
| YES
| | NULL | |
84 | Level | int(
11)
| YES
| | NULL | |
85 +---------------+-------------+------+-----+---------+-------+
86 5 rows
in set (
0.00 sec)
87
88 mysql
> insert into qq_user
values(
‘123344‘,
‘xiaoguo‘,
‘2014-1-1‘,
‘1‘,
‘2‘);
89 Query OK,
1 row affected (
0.00 sec)
90
91 mysql
> select *from qq_user;
92 +--------+----------+---------------------+-------+-------+
93 | qq_id
| Password
| LastLoginTime
| Oline
| Level |
94 +--------+----------+---------------------+-------+-------+
95 | 123344 | xiaoguo
| 2014-01-01 00:
00:
00 | 1 | 2 |
96 +--------+----------+---------------------+-------+-------+
97 1 row
in set (
0.00 sec)
98
99 mysql
>
100 mysql
>
101 mysql
> truncate qq_user;
102 Query OK,
0 rows affected (
0.00 sec)
103
104 mysql
> selcet
*from qq_user;
105 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
‘selcet *from qq_user‘ at line
1
106 mysql
> show tables;
107 +------------------+
108 | Tables_in_systop
|
109 +------------------+
110 | qq_user
|
111 +------------------+
112 1 row
in set (
0.00 sec)
113
114 mysql
> select * from qq_user;
115 Empty
set (
0.00 sec)
116
117 mysql
> alter table qq_user rename
user;
118 Query OK,
0 rows affected (
0.00 sec)
119
120 mysql
> show tables;
121 +------------------+
122 | Tables_in_systop
|
123 +------------------+
124 | user |
125 +------------------+
126 1 row
in set (
0.00 sec)
127
128 mysql
> alter table user modify qq_id
int;
129 Query OK,
0 rows affected (
0.00 sec)
130 Records:
0 Duplicates:
0 Warnings:
0
131
132 mysql
> desc user;
133 +---------------+-------------+------+-----+---------+-------+
134 | Field
| Type
| Null | Key | Default | Extra
|
135 +---------------+-------------+------+-----+---------+-------+
136 | qq_id
| int(
11)
| NO
| PRI
| 0 | |
137 | Password
| varchar(
50)
| NO
| | NULL | |
138 | LastLoginTime
| datetime | YES
| | NULL | |
139 | Oline
| int(
11)
| YES
| | NULL | |
140 | Level | int(
11)
| YES
| | NULL | |
141 +---------------+-------------+------+-----+---------+-------+
142 5 rows
in set (
0.00 sec)
143
144 mysql
> alter table user qq_id
bigint(
6);
145 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
‘qq_id bigint(6)‘ at line
1
146 mysql
> alter table user modify qq_id
bigint(
6);
147 Query OK,
0 rows affected (
0.00 sec)
148 Records:
0 Duplicates:
0 Warnings:
0
149
150 mysql
> desc user;
151 +---------------+-------------+------+-----+---------+-------+
152 | Field
| Type
| Null | Key | Default | Extra
|
153 +---------------+-------------+------+-----+---------+-------+
154 | qq_id
| bigint(
6)
| NO
| PRI
| 0 | |
155 | Password
| varchar(
50)
| NO
| | NULL | |
156 | LastLoginTime
| datetime | YES
| | NULL | |
157 | Oline
| int(
11)
| YES
| | NULL | |
158 | Level | int(
11)
| YES
| | NULL | |
159 +---------------+-------------+------+-----+---------+-------+
160 5 rows
in set (
0.00 sec)
161
162 mysql
>
163 mysql
>
164 mysql
> alter table user change qq_id id
165 -> ;
166 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
‘‘ at line
1
167 mysql
> alter table user change qq_id id
int;
168 Query OK,
0 rows affected (
0.01 sec)
169 Records:
0 Duplicates:
0 Warnings:
0
170
171 mysql
> desc user;
172 +---------------+-------------+------+-----+---------+-------+
173 | Field
| Type
| Null | Key | Default | Extra
|
174 +---------------+-------------+------+-----+---------+-------+
175 | id
| int(
11)
| NO
| PRI
| 0 | |
176 | Password
| varchar(
50)
| NO
| | NULL | |
177 | LastLoginTime
| datetime | YES
| | NULL | |
178 | Oline
| int(
11)
| YES
| | NULL | |
179 | Level | int(
11)
| YES
| | NULL | |
180 +---------------+-------------+------+-----+---------+-------+
181 5 rows
in set (
0.00 sec)
182
183 mysql
> alter table user add Name
varchar(
20) after id;
184 Query OK,
0 rows affected (
0.01 sec)
185 Records:
0 Duplicates:
0 Warnings:
0
186
187 mysql
> desc user;
188 +---------------+-------------+------+-----+---------+-------+
189 | Field
| Type
| Null | Key | Default | Extra
|
190 +---------------+-------------+------+-----+---------+-------+
191 | id
| int(
11)
| NO
| PRI
| 0 | |
192 | Name
| varchar(
20)
| YES
| | NULL | |
193 | Password
| varchar(
50)
| NO
| | NULL | |
194 | LastLoginTime
| datetime | YES
| | NULL | |
195 | Oline
| int(
11)
| YES
| | NULL | |
196 | Level | int(
11)
| YES
| | NULL | |
197 +---------------+-------------+------+-----+---------+-------+
198 6 rows
in set (
0.00 sec)
199
200 mysql
> alter table user drop Name;
201 Query OK,
0 rows affected (
0.00 sec)
202 Records:
0 Duplicates:
0 Warnings:
0
203
204 mysql
> desc user;
205 +---------------+-------------+------+-----+---------+-------+
206 | Field
| Type
| Null | Key | Default | Extra
|
207 +---------------+-------------+------+-----+---------+-------+
208 | id
| int(
11)
| NO
| PRI
| 0 | |
209 | Password
| varchar(
50)
| NO
| | NULL | |
210 | LastLoginTime
| datetime | YES
| | NULL | |
211 | Oline
| int(
11)
| YES
| | NULL | |
212 | Level | int(
11)
| YES
| | NULL | |
213 +---------------+-------------+------+-----+---------+-------+
214 5 rows
in set (
0.00 sec)
215
216 mysql
> alter table user modify
Level int after Password;
217 Query OK,
0 rows affected (
0.00 sec)
218 Records:
0 Duplicates:
0 Warnings:
0
219
220 mysql
> desc user;
221 +---------------+-------------+------+-----+---------+-------+
222 | Field
| Type
| Null | Key | Default | Extra
|
223 +---------------+-------------+------+-----+---------+-------+
224 | id
| int(
11)
| NO
| PRI
| 0 | |
225 | Password
| varchar(
50)
| NO
| | NULL | |
226 | Level | int(
11)
| YES
| | NULL | |
227 | LastLoginTime
| datetime | YES
| | NULL | |
228 | Oline
| int(
11)
| YES
| | NULL | |
229 +---------------+-------------+------+-----+---------+-------+
230 5 rows
in set (
0.00 sec)
231
232 mysql
> alter table user modify id
bigint(
6);
233 Query OK,
0 rows affected (
0.00 sec)
234 Records:
0 Duplicates:
0 Warnings:
0
235
236 mysql
> desc user;
237 +---------------+-------------+------+-----+---------+-------+
238 | Field
| Type
| Null | Key | Default | Extra
|
239 +---------------+-------------+------+-----+---------+-------+
240 | id
| bigint(
6)
| NO
| PRI
| 0 | |
241 | Password
| varchar(
50)
| NO
| | NULL | |
242 | Level | int(
11)
| YES
| | NULL | |
243 | LastLoginTime
| datetime | YES
| | NULL | |
244 | Oline
| int(
11)
| YES