Archives: database

mysql transcations No ratings yet.

Generally how to write transaction Begin transaction by issuing the SQL command BEGIN WORK. Issue one or more SQL commands like SELECT, INSERT, UPDATE or DELETE. Check if there is no error and everything is according to your requirement. If there is any error, then issue a ROLLBACK command, otherwise issue a COMMIT command.   how • Read More »



Postgresql cheatsheat 5/5 (1)

Connecting to MySQL:  mysql -u user_name -p Connecting to PostgreSQL: sudo -u postgres psql Description MySQL command PostgreSQL equivalent Show databases SHOW DATABASES; \l[ist] Use/Connect to a database named ‘some_database’ USE some_database; \c some_database Show tables/relations within one database SHOW TABLES; \dt Show table details (columns, types) DESCRIBE some_table; \d+ some_table Show indices of some_table (in • Read More »


MySQL Binary field how to insert, search No ratings yet.

http://www.ovaistariq.net/632/understanding-mysql-binary-and-non-binary-string-data-types/ http://artarmstrong.com/blog/2014/12/07/store-uuid-as-binary16-mysql-data-type/ http://stackoverflow.com/questions/9081216/mysql-insert-statement-to-binary-datatype e.g: CREATE TABLE `Test` ( `myhash` binary(16) DEFAULT NULL ) Insert 10E8400E29B11D4A716446655440000 as HEX representation of some chars Insert into `Test` values ( UNHEX(“110E8400E29B11D4A716446655440000”) ); MySQL standard is to use this notation to denote the string as binary… X’9fad5e9eefdfb449′ insertinto assignedresource values(X’9fad5e9eefdfb449′); Search select hex(myhash) from Test where myhash=UNHEX(“110E8400E29B11D4A716446655440001”); Please rate this • Read More »