To create a table, use:
mysql> CREATE TABLE data(
-> id INT NOT NULL AUTO_INCREMENT KEY,
-> name CHAR(20),
-> city CHAR(20));
To lookup the structure of the table,use:
mysql> DESC data; # argument is table name
To insert some data, type
mysql> INSERT INTO data
-> values
-> (null,'steve jobs','cupertino'),
-> (null,'larry page','mountain view'),
-> (null,'aura kasih','jakarta');
or
mysql> INSERT INTO data (name, city)
-> values
-> ('lady gaga','new york');
To lookup what the contents of the table, type:
mysql> SELECT * FROM data; // argument is table name
or
mysql> SELECT name, city FROM data; // based on columns name
or
mysql> SELECT * FROM data ORDER BY id ASC; // or DESC
or
mysql> SELECT * FROM data WHERE id>2; // then ORDER BY
To delete a content of data,type
mysql> DELETE FROM satu
-> WHERE id=1; // delete steve jobs rows
To update a content of data, type
mysql> UPDATE satu
-> SET name='luna maya', city='denpasar'
-> WHERE id=2; // update larry page
No comments:
Post a Comment