Test 123: различия между версиями

Материал из noname.com.ua
Перейти к навигацииПерейти к поиску
Строка 29: Строка 29:
 
UNIQUE KEY `host_network` (`hostname`,`network`),
 
UNIQUE KEY `host_network` (`hostname`,`network`),
 
UNIQUE KEY `ip` (`ip`,`mac`)
 
UNIQUE KEY `ip` (`ip`,`mac`)
) ENGINE=MyISAM AUTO_INCREMENT=3157 DEFAULT CHARSET=latin1 COMMENT='Dhcphosts hosts'
+
) ENGINE=MyISAM AUTO_INCREMENT=3157 DEFAULT CHARSET=latin1 COMMENT='Dhcphosts hosts';
 
</PRE>
 
</PRE>
 
   
 
===view_active_users===
 
===view_active_users===

Версия 13:33, 29 октября 2011

Тут заметки о переезде.

Дополнительные таблички

dhcphosts_hosts_new

Нужна копия. Потом сделаем вьюху старая --> новая. Пока так.

CREATE TABLE `dhcphosts_hosts_new` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `uid` int(11) NOT NULL DEFAULT '0',
  `ip` int(10) unsigned NOT NULL DEFAULT '0',
  `hostname` varchar(40) NOT NULL DEFAULT '',
  `network` smallint(5) unsigned NOT NULL DEFAULT '0',
  `mac` varchar(17) NOT NULL DEFAULT '00:00:00:00:00:00',
  `disable` tinyint(1) unsigned NOT NULL DEFAULT '0',
  `forced` int(1) NOT NULL DEFAULT '0',
  `blocktime` int(3) unsigned NOT NULL DEFAULT '3',
  `expire` date NOT NULL DEFAULT '0000-00-00',
  `seen` int(1) NOT NULL DEFAULT '0',
  `comments` varchar(250) NOT NULL DEFAULT '',
  `vid` smallint(6) unsigned NOT NULL DEFAULT '0',
  `nas` bigint(20) DEFAULT NULL,
  `option_82` tinyint(1) unsigned NOT NULL DEFAULT '0',
  `ports` varchar(100) NOT NULL DEFAULT '',
  `boot_file` varchar(150) NOT NULL DEFAULT '',
  `changed` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  PRIMARY KEY (`id`),
  UNIQUE KEY `cid` (`ip`),
  UNIQUE KEY `host_network` (`hostname`,`network`),
  UNIQUE KEY `ip` (`ip`,`mac`)
) ENGINE=MyISAM AUTO_INCREMENT=3157 DEFAULT CHARSET=latin1 COMMENT='Dhcphosts hosts';

view_active_users

DROP VIEW view_active_users;
CREATE VIEW view_active_users AS 
SELECT 
users.uid AS uid,
users.id  AS user,
inet_ntoa(dhcphosts_hosts_new.ip) AS ip,
dhcphosts_networks_vlans.vlan AS vlan 
FROM 
( dhcphosts_networks_vlans join dhcphosts_hosts on ((dhcphosts_networks_vlans.vlan = dhcphosts_hosts.vid)) 
join 
dhcphosts_networks on (dhcphosts_networks.id = dhcphosts_networks_vlans.id ))    
join 
users on((users.uid = dhcphosts_hosts_new.uid))  
join
bills on ((users.bill_id = bills.id)) 
WHERE ( bills.deposit > 0 );