Insert a record in mysql and return the record id
1.select max(id) from user;
2.select last_insert_id() as id from user limit 1;
(The return id of this test has always been 0, a bit of a problem)
3. Stored process
1)
In oracel
create sequence seqID
minvalue 1
maxvalue 999999999999999999999999999
start with 1
increment by 1
increment by 1
p>
nocache
order;
create or replace procedure sp_insert(aName int,rst out int) is
begin
insert into tablename(id,name) values(seqID.nextval,aName);
rst:=seqID.currval;
end;
2) Implementation in mysql
DELIMITER $$
DROP PROCEDURE IF EXISTS `test` $$
CREATE DEFINER=& #96;root`@`localhost`PROCEDURE`test`(in name varchar(100),out oid int)
BEGIN
BEGIN
insert into user(loginname) values(name);
select max(id) from user into oid;
select oid;
END $$
DELIMITER ;
Then execute
call test('gg',@id);
Just return id
Related documents :
Administration management
Kill a Thread End a thread
mysql > KILL 999;
Optimize Table optimize table
mysql > OPTIMEZE TABLE foo;
Reload Users Permissions refresh MySQL system permission related tables
mysql > FLUSH PRIVILEGES;
Repair Table Repair Table
mysql > …
destroy-method=”close”>
Create database:
mysql>create database test;
Query OK, 1 row affected (0.02 sec)
Create Database table :
mysql>use test;
Database changed
create database table :
myaql> create table user(SID VARCHAR(11), name VARCHAT(6) );
Query OK, 0 rows affected (0.08 sec)
Insert record:
mysql>insert int use ……
The installed OS is Solaris10, and the mysql version is 5.1.38
1. Use the RPM package for installation
p>
First, you can download the corresponding version of the rpm package from the installation CD or the mysql website as follows :
MySQL-server-community-5.1.38-0.rhel5.i386 .rpm
MySQL-client-community-5.1.38-0.rhel5.i386.rpm
Then we can use the rpm command……