Test your skills through the online practice test: MySQL Quiz Online Practice Test

Related differences

Ques 76. What Happens If You No CREATE Privilege in a Database?

In order to create tables in a database, your user account must have the CREATE privilege for that database. Otherwise you will get an error as shown in the following tutorial exercise:

>cd mysqlbin
>mysql -u guest -ppub

mysql> use ggl;
Database changed

mysql> CREATE TABLE test (id integer);
ERROR 1142 (42000): CREATE command denied to user
'guest'@'localhost' for table 'test'

If you get this error, you need to see the DBA to obtain the CREATE privilege.

Is it helpful? Add Comment View Comments
 

Ques 77. How To Include Comments in SQL Statements?

If you want to include comments in a SQL statement, you can first enter "--", then enter your comment until the end of the line. The tutorial exercise below shows you some good examples:

SELECT 'Hello world!' FROM DUAL; -- My first SQL statement!

INSERT INTO links VALUES ('GlobalGuideLine.com'); -- Top rated!

CREATE TABLE faq (
id INTEGER, -- primary key
title VARCHAR(80) -- FAQ title
);

Is it helpful? Add Comment View Comments
 

Ques 78. How To Get a List of All Tables in a Database?

If you want to see the table you have just created, you can use the "SHOW TABLES" command to get a list of all tables in database. The tutorial script gives you a good example:

mysql> SHOW TABLES;
+---------------+

| Tables_in_ggl |

+---------------+

| links |

| tip |

+---------------+

3 rows in set (0.00 sec)

Is it helpful? Add Comment View Comments
 

Ques 79. How To Include Character Strings in SQL statements?

If you want to include character strings in your SQL statements, you need to quote them in one of the following formats:

► Using single quotes. For example 'GlobalGuideLine.com'.
► Using double quotes. For example "ggl Center".
► Using single quotes prefixed with N for NATIONAL characters (same as UTF8 characters). For example N'Allo, Francois.'.
► Using single quotes prefixed with _utf8 for UTF8 characters. For example _utf8'Allo, Francois.'.

Is it helpful? Add Comment View Comments
 

Ques 80. How To Get a List of Columns in an Existing Table?

mysql> SHOW COLUMNS FROM test;

Is it helpful? Add Comment View Comments
 

Most helpful rated by users: