Professional Documents
Culture Documents
New Things: Select From Where Create Select From
New Things: Select From Where Create Select From
1. 2. 3. ROW CONSTRUCTOR : SETTING USER VARIABLES: SET @VAR_NAME = VALUE .IF PART OF QUERY USE := FOR ASSIGNMENT ADDING FULL TEXT SEARCH:
ALTER TABLE employee ADD FULLTEXT (first_name); Works on myisam only, ALTER TABLE TABLE_NAME ENGINE = MYISAM IF HAVE TO SEARCH RELEVANT DATA FIRST SELECT first_name, MATCH(first_name) AGAINST ('J') AS Rating FROM employee WHERE MATCH(first_name) AGAINST ('J');
4. TEMPORARY TABLE
CREATE TEMPORARY TABLE <newtable> SELECT * FROM <oldtable> drop TEMPORARY TABLE tempEmployee;
5. CREATING INDEXES
CREATE INDEX id_index ON employee(id); ALTER table myTable add index(name); DROP INDEX indexname ON tablename; Or ALTER TABLE tablename DROP INDEX indexname; ALTER TABLE Employee ADD KEY myIndex (id);
ALTER TABLE Employee ADD INDEX myIndex (id, first_name);
SHOW indexes FROM Employee; CREATE UNIQUE INDEX myIndex ON Employee (id);
6. REPLACE [ ]
7. REPLACE [LOW_PRIORITY | DELAYED] 8. 9. [INTO] tbl_name [(col_name,...)] {VALUES | VALUE} ({expr | DEFAULT},...),(...),...
10. Or:
11. REPLACE [LOW_PRIORITY | DELAYED] 12. 13. [INTO] tbl_name SET col_name={expr | DEFAULT}, ...
14. Or:
15. REPLACE [LOW_PRIORITY | DELAYED] 16. [INTO] tbl_name [(col_name,...)]
17.
SELECT ...
18. REPLACE works exactly like INSERT, except that if an old row in the table has the same value as a new row for aPRIMARY KEY or a UNIQUE index, the old row is deleted before the new row is inserted.
7 INSERTING QUOTES Inserting single quotes : kenniths Inserting double quotes: Kenneths START TRANSACTION
START TRANSACTION [WITH CONSISTENT SNAPSHOT] BEGIN [WORK] COMMIT [WORK] [AND [NO] CHAIN] [[NO] RELEASE] ROLLBACK [WORK] [AND [NO] CHAIN] [[NO] RELEASE] SET autocommit = {0 | 1}
By default, MySQL runs with autocommit mode enabled. This means that as soon as you execute a statement that updates (modifies) a table, MySQL stores the update on disk to make it permanent.