示例#1
0
        public void GetDatabaseInfo(MySqlCommand cmd, bool getTotalRowsForEachTable)
        {
            _name = QueryExpress.ExecuteScalarStr(cmd, "SELECT DATABASE();");
            _defaultCharSet = QueryExpress.ExecuteScalarStr(cmd, "SHOW VARIABLES LIKE 'character_set_database';", 1);
            _createDatabaseSql = QueryExpress.ExecuteScalarStr(cmd, string.Format("SHOW CREATE DATABASE `{0}`;", _name), 1).Replace("CREATE DATABASE", "CREATE DATABASE IF NOT EXISTS") + ";";
            _dropDatabaseSql = string.Format("DROP DATABASE IF EXISTS `{0}`;", _name);

            _listTable = new MySqlTableList(cmd);
            _listProcedure = new MySqlProcedureList(cmd);
            _listFunction = new MySqlFunctionList(cmd);
            _listTrigger = new MySqlTriggerList(cmd);
            _listEvent = new MySqlEventList(cmd);
            _listView = new MySqlViewList(cmd);

            if (getTotalRowsForEachTable)
                GetTotalRows(cmd);
        }
示例#2
0
        public void GetDatabaseInfo(MySqlCommand cmd, bool getTotalRowsForEachTable)
        {
            _name              = QueryExpress.ExecuteScalarStr(cmd, "SELECT DATABASE();");
            _defaultCharSet    = QueryExpress.ExecuteScalarStr(cmd, "SHOW VARIABLES LIKE 'character_set_database';", 1);
            _createDatabaseSql = QueryExpress.ExecuteScalarStr(cmd, string.Format("SHOW CREATE DATABASE `{0}`;", _name), 1).Replace("CREATE DATABASE", "CREATE DATABASE IF NOT EXISTS") + ";";
            _dropDatabaseSql   = string.Format("DROP DATABASE IF EXISTS `{0}`;", _name);

            _listTable     = new MySqlTableList(cmd);
            _listProcedure = new MySqlProcedureList(cmd);
            _listFunction  = new MySqlFunctionList(cmd);
            _listTrigger   = new MySqlTriggerList(cmd);
            _listEvent     = new MySqlEventList(cmd);
            _listView      = new MySqlViewList(cmd);

            if (getTotalRowsForEachTable)
            {
                GetTotalRows(cmd);
            }
        }
示例#3
0
        public void GetDatabaseInfo(MySqlCommand cmd, bool getTotalRowsForEachTable)
        {
            Name = QueryExpress.ExecuteScalarStr(cmd, "SELECT DATABASE();");
            DefaultCharacterSet = QueryExpress.ExecuteScalarStr(cmd, "SHOW VARIABLES LIKE 'character_set_database';", 1);
            CreateDatabaseSql   =
                QueryExpress.ExecuteScalarStr(cmd, $"SHOW CREATE DATABASE `{Name}`;", 1)
                .Replace("CREATE DATABASE", "CREATE DATABASE IF NOT EXISTS") + ";";
            DropDatabaseSql = $"DROP DATABASE IF EXISTS `{Name}`;";

            Tables     = new MySqlTableList(cmd);
            Procedures = new MySqlProcedureList(cmd);
            Functions  = new MySqlFunctionList(cmd);
            Triggers   = new MySqlTriggerList(cmd);
            Events     = new MySqlEventList(cmd);
            Views      = new MySqlViewList(cmd);

            if (getTotalRowsForEachTable)
            {
                GetTotalRows(cmd);
            }
        }
示例#4
0
        public void GetDatabaseInfo(string conn, GetTotalRowsMethod enumGetTotalRowsMode)
        {
            MySqlCommand cmd = new MySqlCommand();

            cmd.Connection = new MySqlConnection(conn);
            cmd.Connection.Open();
            _name              = QueryExpress.ExecuteScalarStr(cmd, "SELECT DATABASE();");
            _defaultCharSet    = QueryExpress.ExecuteScalarStr(cmd, "SHOW VARIABLES LIKE 'character_set_database';", 1);
            _createDatabaseSql = QueryExpress.ExecuteScalarStr(cmd, string.Format("SHOW CREATE DATABASE `{0}`;", _name), 1).Replace("CREATE DATABASE", "CREATE DATABASE IF NOT EXISTS") + ";";
            _dropDatabaseSql   = string.Format("DROP DATABASE IF EXISTS `{0}`;", _name);
            _listTable         = new MySqlTableList(cmd);
            cmd.Connection.Close();

            //            SELECT
            //CONCAT_WS(' ',
            //        'DELIMITER $$\n',
            //        'CREATE ',
            //        CONCAT_WS('=', r.SECURITY_TYPE, CONCAT_WS('@', CONCAT('`', SUBSTRING_INDEX(r.`definer`, '@', 1), '`'), CONCAT('`', SUBSTRING_INDEX(r.`definer`, '@', -1), '`'))),
            //        '\n',
            //        r.ROUTINE_TYPE,
            //        CONCAT_WS('.', ROUTINE_SCHEMA, ROUTINE_NAME),
            //        CONCAT('(', GROUP_CONCAT(CONCAT_WS(' ', p.PARAMETER_NAME, p.DTD_IDENTIFIER)), ')'),
            //        IF(o_p.DTD_IDENTIFIER is not null, CONCAT('RETURNS ', o_p.DTD_IDENTIFIER), ''),
            //        ROUTINE_DEFINITION,
            //        '$$') stmt_ FROM information_schema.routines r
            //LEFT JOIN information_schema.parameters p
            //ON p.SPECIFIC_SCHEMA = r.routine_schema AND
            //p.specific_name = r.routine_name AND p.PARAMETER_MODE = 'IN'
            //LEFT JOIN information_schema.parameters o_p ON o_p.SPECIFIC_SCHEMA =
            // r.routine_schema AND o_p.specific_name = r.routine_name AND o_p.PARAMETER_MODE
            // IS NULL WHERE ROUTINE_SCHEMA IN('grt_talentoz')
            //GROUP BY
            //CONCAT_WS('.', ROUTINE_SCHEMA, ROUTINE_NAME)
            var pro = Task.Factory.StartNew(() =>
            {
                MySqlCommand cmd1 = new MySqlCommand();
                cmd1.Connection   = new MySqlConnection(conn);
                cmd1.Connection.Open();
                _listProcedure = new MySqlProcedureList(cmd1);
                cmd1.Connection.Close();
            });

            var fn = Task.Factory.StartNew(() =>
            {
                MySqlCommand cmd1 = new MySqlCommand();
                cmd1.Connection   = new MySqlConnection(conn);
                cmd1.Connection.Open();
                _listFunction = new MySqlFunctionList(cmd1);
                cmd1.Connection.Close();
            });
            var trg = Task.Factory.StartNew(() =>
            {
                MySqlCommand cmd1 = new MySqlCommand();
                cmd1.Connection   = new MySqlConnection(conn);
                cmd1.Connection.Open();
                _listTrigger = new MySqlTriggerList(cmd1);
                cmd1.Connection.Close();
            });
            var evnt = Task.Factory.StartNew(() =>
            {
                MySqlCommand cmd1 = new MySqlCommand();
                cmd1.Connection   = new MySqlConnection(conn);
                cmd1.Connection.Open();
                _listEvent = new MySqlEventList(cmd1);
                cmd1.Connection.Close();
            });
            var vw = Task.Factory.StartNew(() =>
            {
                MySqlCommand cmd1 = new MySqlCommand();
                cmd1.Connection   = new MySqlConnection(conn);
                cmd1.Connection.Open();
                _listView = new MySqlViewList(cmd1);
                cmd1.Connection.Close();
            });

            Task.WaitAll(pro, fn, trg, evnt, vw);


            if (enumGetTotalRowsMode != GetTotalRowsMethod.Skip)
            {
                GetTotalRows(cmd, enumGetTotalRowsMode);
            }
        }