[ SDF Public Access UNIX System .. Est. 1987 ]

join welcome faq status members store tour gopher abuse dialup minecraft
social tilde europa webmail gallery usermap irc tutorials telnet git ssh

[03] IS THERE AN SQL PRIMER I CAN USE?

     MySQL conforms pretty much to SQL92.  There are many 
     documents/tutorials/faqs available on the net .. besides that,
     its beyond the scope of the SDF FAQ to cover this. 

     HOWEVER, here are a few quick commands to get your started!
     The best way to learn SQL is by using it.

     (SQL commands are in UPPER CASE, objects are in lowercase)

     CREATING A TABLE
     ----------------

     CREATE TABLE test (
     name VARCHAR (15),
     email VARCHAR (25),
     phone INT,
     ID INT NOT NULL AUTO_INCREMENT,
     PRIMARY KEY (ID));

     DESCRIBING A TABLE
     ------------------

     DESC test;

     +-------+-------------+------+-----+---------+----------------+
     | Field | Type        | Null | Key | Default | Extra          |
     +-------+-------------+------+-----+---------+----------------+
     | name  | varchar(15) | YES  |     | NULL    |                |
     | email | varchar(25) | YES  |     | NULL    |                |
     | phone | int(11)     | YES  |     | NULL    |                |
     | ID    | int(11)     |      | PRI | NULL    | auto_increment |
     +-------+-------------+------+-----+---------+----------------+

     INSERTING A ROW INTO A TABLE
     ----------------------------

     INSERT INTO test VALUES 
     ('Ted Uhlemann', 'iczer@sdf.org', '5551212', NULL);

     SELECTING RECORDS FROM A TABLE
     ------------------------------
 
     SELECT * FROM test;

     +--------------+------------------------+---------+----+
     | name         | email                  | phone   | ID |
     +--------------+------------------------+---------+----+
     | Ted Uhlemann | iczer@sdf.org          | 5551212 |  1 |
     +--------------+------------------------+---------+----+

     DELETING A ROW FROM A TABLE
     ---------------------------

     DELETE FROM test;

     ALTER A TABLE
     -------------
      
     ALTER TABLE test RENAME friends;

     ALTER TABLE friends ADD birthday DATE;

     ALTER TABLE friends CHANGE name fullname VARCHAR (25);
   
     ALTER TABLE friends DROP name;
     
     UPDATING A ROW
     --------------

     UPDATE test SET email = 'iczer@sdf.org'; 

     UPDATE friends SET birthday = '1978-06-16' WHERE id = '1';

     DROPPING A TABLE
     ----------------
     
     DROP TABLE friends;

     COPY DATA BETWEEN TABLES
     ------------------------

     INSERT IGNORE INTO wp2_posts SELECT * FROM wp_posts;

[back]


©1987-2065 SDF Public Access UNIX System, Inc. 501(c)(7)
(this page was generated using ksh, sed and awk)